zoukankan      html  css  js  c++  java
  • eureka学习(一)

    eureka是一个注册中心,与zookeeper不同的是,eureka是restful格式的调用,zk是rpc,还有就是zk保证一致和容错,eureka则是可用和容错.

    使用时首先要加入依赖

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>

    yml文件里

    server:
      port: 7001
    eureka:
      instance:
        hostname: localhost   #eureka服务端的实例名称 
      client:
        register-with-eureka: false  #falsege表示不向注册 中心注册自己
        fetch-registry: false           #不需要去检索服务 
        service-url:
          defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/   #设置与eureka server交互的地址查询服务和注册 服务的地址

    主启动类里面

    @SpringBootApplication
    @EnableEurekaServer  //标注为eureka服务端
    public class EurekaServerApp {
        public static void main(String[] args) {
            SpringApplication.run(EurekaServerApp.class,args);
        }
    }

    接着可以启动,启动好后在浏览器里输入http://locahost:7001就看到eureka的页面了。

    注意:

      有时候会报错,可能是引入包冲突了,官网给了如下建议:

    Finchley builds and works with Spring Boot 2.0.x, and is not expected to work with Spring Boot 1.5.x.

    Note: The Dalston release train will reach end-of-life in December 2018. Edgware will follow the end-of-life cycle of Spring Boot 1.5.x.

    The Dalston and Edgware release trains build on Spring Boot 1.5.x, and are not expected to work with Spring Boot 2.0.x.

    NOTE: The Camden release train was marked end-of-life.

    The Camden release train builds on Spring Boot 1.4.x, but is also tested with 1.5.x.

    NOTE: The Brixton and Angel release trains were marked end-of-life (EOL) in July 2017.

    The Brixton release train builds on Spring Boot 1.3.x, but is also tested with 1.4.x.

    The Angel release train builds on Spring Boot 1.2.x, and is incompatible in some areas with Spring Boot 1.3.x. Brixton builds on Spring Boot 1.3.x and is similarly incompatible with 1.2.x. Some libraries and most apps built on Angel will run fine on Brixton, but changes will be required anywhere that the OAuth2 features from spring-cloud-security 1.0.x are used (they were mostly moved to Spring Boot in 1.3.0).

    ...
  • 相关阅读:
    javamail模拟邮箱功能发送电子邮件-基础实战篇(javamail API电子邮件实例)
    javaScript的函数(Function)对象的声明(@包括函数声明和函数表达式)
    java后台调用HttpURLConnection类模拟浏览器请求(一般用于接口调用)
    java 常用concurrent类
    安装php5.5
    Unix 哲学
    mysql创建用户两次授权
    python知识点 07-11
    Gradle 1.3之前的Publishing artifacts
    mysql编码详解
  • 原文地址:https://www.cnblogs.com/javage/p/9491643.html
Copyright © 2011-2022 走看看