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).

    ...
  • 相关阅读:
    SQL Server sql 操作
    MYSQL获取自增ID的四种方法
    Mysql自增字段
    三种JDBC批量插入编程方法的比较
    C3P0连接池使用小结
    数据库连接池 c3p0 demo 代码和分析
    Eclipse 安装对 Java 8 的支持
    Java读取Properties文件的六种方法
    常备软件及必要配置
    HBase-存储-概览
  • 原文地址:https://www.cnblogs.com/javage/p/9491643.html
Copyright © 2011-2022 走看看