![cover](https://img-blog.csdnimg.cn/direct/47e046279b23494e93e1266efd7b3b01.png)
Eureka切换Nacos时发现两个注册中心的解决方法
当我想将注册中心从eureka切换为nacos时,不仅需要注释掉eureka客户端的依赖,还需要注释掉eureka服务端的依赖。报错信息如下,意思是发现了两个注册中心。
·
报错信息如下,意思是发现了两个注册中心
Field autoServiceRegistration in org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration required a single bean, but 2 were found:
- nacosAutoServiceRegistration: defined by method 'nacosAutoServiceRegistration' in class path resource [com/alibaba/cloud/nacos/registry/NacosServiceRegistryAutoConfiguration.class]
- eurekaAutoServiceRegistration: defined by method 'eurekaAutoServiceRegistration' in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.class]
首先我们看一下工程目录:
eureka-server是我的eureka服务端,order-server和user-server是我的eureka客户端,在eureka服务端中引入了服务端依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
在两个eureka客户端中引入了客户端依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
当我想将注册中心从eureka切换为nacos时,不仅需要注释掉eureka客户端的依赖,还需要注释掉eureka服务端的依赖。
更多推荐
所有评论(0)