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

报错信息如下,意思是发现了两个注册中心

java 复制代码
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服务端中引入了服务端依赖:

java 复制代码
<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

在两个eureka客户端中引入了客户端依赖:

java 复制代码
<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

当我想将注册中心从eureka切换为nacos时,不仅需要注释掉eureka客户端的依赖,还需要注释掉eureka服务端的依赖。

相关推荐
迷路剑客1 分钟前
ES-7.10-高亮HighLight知识点总结
java·数据库·mybatis
阿蒙Amon6 分钟前
C#每日面试题-简述泛型约束
java·开发语言·c#
Wpa.wk29 分钟前
持续集成 - 持续集成工具-Jenkins的部署流程
java·运维·经验分享·ci/cd·自动化·jenkins
佳哥的技术分享39 分钟前
Function<T, R> 中 apply,compose, andThen 方法总结
java·学习·r语言
wangmengxxw42 分钟前
SpringAI-结构化输出API
java·人工智能·springai
0和1的舞者44 分钟前
基于Spring的论坛系统-前置知识
java·后端·spring·系统·开发·知识
咕噜企业分发小米44 分钟前
腾讯云和火山引擎在多云管理工具上如何实现成本优化?
java·腾讯云·火山引擎
不平衡的叉叉树1 小时前
从JDK 1.8到JDK 21:实用新特性
java
鱼跃鹰飞1 小时前
Leetcode1027:最长等差数列
java·数据结构·算法