@EnableDiscoveryClient与@EnableEurekaClient 区别

Eureka依赖:

<dependency>
     <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

启动类:

@EnableEurekaClient

@SpringBootApplication

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

yml配置:

spring:
   application:
      name: app-order
eureka:
  client:
     serviceUrl:
         defaultZone: http://localhost:8080/eureka/

相同点:在启动类上面添加 @EnableDiscoveryClient、@EnableEurekaClient  这二个注解作用,都可以让该服务注册到注册中心上去。

不同点:@EnableEurekaClient 只支持Eureka注册中心,@EnableDiscoveryClient 支持Eureka、Zookeeper、Consul 这三个注册中心。

 

posted @ 2019-04-02 10:04  明天,你好啊  阅读(6551)  评论(0编辑  收藏  举报