报错信息如下,意思是发现了两个注册中心
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客户端中引入了客户端依赖:文章来源:https://www.toymoban.com/news/detail-819703.html
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
当我想将注册中心从eureka切换为nacos时,不仅需要注释掉eureka客户端的依赖,还需要注释掉eureka服务端的依赖。文章来源地址https://www.toymoban.com/news/detail-819703.html
到了这里,关于Eureka切换Nacos时发现两个注册中心的解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!