spring cloud eureka 初始化报错(A bean with that name has already been defined)

报错内容

The bean 'eurekaRegistration', defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration E u r e k a C l i e n t C o n f i g u r a t i o n . c l a s s ] , c o u l d n o t b e r e g i s t e r e d . A b e a n w i t h t h a t n a m e h a s a l r e a d y b e e n d e f i n e d i n c l a s s p a t h r e s o u r c e [ o r g / s p r i n g f r a m e w o r k / c l o u d / n e t f l i x / e u r e k a / E u r e k a C l i e n t A u t o C o n f i g u r a t i o n EurekaClientConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration EurekaClientConfiguration.class],couldnotberegistered.Abeanwiththatnamehasalreadybeendefinedinclasspathresource[org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationRefreshableEurekaClientConfiguration.class] and overriding is disabled.

排查

原因大概就是依赖冲突、版本冲突之类的,根据以下答案尝试后没有修复:

https://stackoverflow.com/questions/62868281/bean-eurekaregistration-defined-in-class-path-resource-could-not-be-registere

https://developer.baidu.com/article/details/3234921

https://www.volcengine.com/theme/8366164-OTHER-7-1

最后发现引用了 spring-cloud-context,怀疑是版本冲突,去掉后问题修复。

相关推荐
亚林瓜子1 小时前
Spring中的异步任务(CompletableFuture版)
java·spring boot·spring·async·future·异步
neoooo3 小时前
⚙️ Spring Boot × @RequiredArgsConstructor:写出最干净的依赖注入代码
spring boot·后端·spring
好好研究13 小时前
Spring框架 - 开发方式
java·后端·spring
编啊编程啊程14 小时前
【029】智能停车计费系统
java·数据库·spring boot·spring·spring cloud·kafka
java1234_小锋15 小时前
Spring事件监听的核心机制是什么?
java·spring·面试
CodeBlossom19 小时前
Spring Cache快速入门
java·数据库·spring
⑩-19 小时前
如何保证Redis和Mysql数据缓存一致性?
java·数据库·redis·mysql·spring·缓存·java-ee
虎子_layor1 天前
实现异步最常用的方式@Async,快速上手
后端·spring
不光头强1 天前
Spring整合单元测试
spring·单元测试·log4j
没有bug.的程序员1 天前
Eureka 注册中心原理与服务注册发现机制
java·spring·云原生·eureka·架构·注册中心·服务注册发现