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

    ...
  • 相关阅读:
    字符串类型
    mysql-schema-sync 实现 不同环境实例间表结构统一
    order by 运行过程
    MySQL 生成随机测试数据
    MySQL binlog 日志处理
    MySQL 查询优化
    使用 pyenv 管理不同的 Python 版本
    使用 pyenv 管理不同的 Python 版本
    MVC5 已有打开的与此 Command 相关联的 DataReader,必须首先将它关闭。
    在ASP.net MVC中利用ajax配合razor进行局部加载(给页面套好样式以后,一刷新就不合适了,终于找到了解决方案)
  • 原文地址:https://www.cnblogs.com/javage/p/9491643.html
Copyright © 2011-2022 走看看