SpringCloud @EnableEurekaClient 和 @EnableDiscoveryClient 注解作用

1、@EnableEurekaClient 和 @EnableDiscoveryClient 的作用都是能够让注册中心发现、并扫描到该服务

2、@EnableEurekaClient 只对 Eureka 注册中心有效,而 @EnableDiscoveryClient 对 Eureka、Zookeeper、Consul 等注册中心都有效

3、从 SpringCloud Edgware 版本开始, @EnableEurekaClient 和 @EnableDiscoveryClient 注解都可以省略了,只需要在 pom.xml 中引入依赖、在application.yml 上进行相关配置,就可以将微服务注册到注册中心上

4、但是为了起标识作用,最好还是加上 @EnableDiscoveryClient 注解

posted @ 2021-02-01 21:39  变体精灵  阅读(3723)  评论(0编辑  收藏  举报