Spring Clound 系列

2020-02-20  本文已影响0人  BillZhang88

eureka 初步了解

image.png
image.png
@EnableEurekaServer
@SpringBootApplication
public class ServiceApplication {

   public static void main(String[] args) {
       SpringApplication.run(ServiceApplication.class, args);
   }

}

统一使用推荐的yml 文件
server:
 port: 8761
eureka:
 client:
   service-url:
     defaultZone: http://localhost:8761/eureka #localhost一般为服务器ip
   register-with-eureka: false #对于注册中心的优化,不注册本服务
   fetch-registry: false
当然配置文件的端口的不同,可以注册不同的服务,例如:
# erurek的注册中心地址
server:
  port: 789[1:3]  #注册中心的地址
spring:
  application:
    name: eureka-server
eureka:
  client:
    service-url: 
      defaultZone: [http://localhost:7891/eureka,http://localhost:7892/eureka,http://localhost:7893/eureka](http://localhost:7891/eureka,http://localhost:7892/eureka,http://localhost:8763/eureka)
    register-with-eureka: true # 把自己注册到别的eureka
    fetch-registry: false # 注册中心的优化,代表该注册中心服务,不拉取任何的服务列表
上一篇 下一篇

猜你喜欢

热点阅读