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

    ...
  • 相关阅读:
    网页简单模块布局
    Navicat 8 注册密码
    布局黄冈中学
    php导出csv格式文件
    518. 零钱兑换 II
    1813. 句子相似性 III
    ransac算法概述
    c++ 读取文件夹下所有的文件名
    c++ 获取系统时间 写txt string 转 char* 文件改名 文件删除
    1498. 满足条件的子序列数目 二分 快速幂 等比数列前n项和公式
  • 原文地址:https://www.cnblogs.com/javage/p/9491643.html
Copyright © 2020-2023  润新知