zoukankan      html  css  js  c++  java
  • springboot springcloud eureka

    参考: 

    https://www.cnblogs.com/skyblog/p/5133752.html
    http://blog.csdn.net/u012734441/article/details/78256256?locationNum=1&fps=1
    https://www.cnblogs.com/ncjava/p/7149593.html(eureka高可用)
    http://blog.csdn.net/lc0817/article/details/54375802(eureka常见错误及更多配置)。

    开始集成eureka,服务端

    1. pom.xml中添加
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka-server</artifactId>
            </dependency>
    2. 启动类
    @SpringBootApplication
    @EnableEurekaServer
    public class ChilliApplication {
        public static void main(String[] args) {
            SpringApplication.run(ChilliApplication.class, args);
        }
    }
    3. 配置文件
    server:
      port: 55580
      
    spring:
      application: 
        name: asfood-chilli
      profiles:
        active: dev
        
    eureka:
      instance: 
        hostname: localhost
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
    
    logging:
      file: ./logs/chilli.log
    4. 客户端配置

    添加同样的pom依赖;

    配置文件中添加

    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:55580/eureka/

    启动类添加注释:@EnableEurekaClient

    至于@EnableEurekaClient和@EnableDiscoveryClient的区别可以百度,建议的是,使用eureka就用EnableEurekaClient。

    可以通过访问eureka客户端查看已经注册的服务。

  • 相关阅读:
    05 DDMS中logcat的使用
    04项目的目录结构分析与资源引用
    03 Android之我的第一个.hello world 程序
    关于myeclipse的有关操作
    jsp运行原理分析
    JSP简介
    prepareStatement与Statement的区别
    正则表达式
    过滤器的作用和用法
    剑指Offer--数值的整数次方
  • 原文地址:https://www.cnblogs.com/moly/p/7978332.html
Copyright © 2011-2022 走看看