Eureka切换Nacos时发现两个注册中心的解决方法

  • Post author:
  • Post category:其他


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]

报错如上,在网上翻阅大量资料有的说忽略某个注册中心,配置如下:

spring:
  autoconfigure:
    exclude: org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration

有点网友说治标不治本,再次打包同样报错,我发现也有可能是父工程中的依赖导致报错:

注释掉父工程中Eureka依赖,解决报错



版权声明:本文为weixin_55488429原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。