在一次启动中遇到了bean冲突的问题,提示存在两个名称重复的bean
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.test.api.Application]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'healthCheckController' for bean class [com.test.datahub.controller.HealthCheckController] conflicts with existing, non-compatible bean definition of same name and class [com.test.api.controller.HealthCheckController]
项目中包括多个模块,其中A、B两个模块都有同一个类:HealthCheckController,检查更改信息发现,不知道谁在A模块添加了B模块的依赖,造成了这一问题,删除后解决
<dependency>
<groupId>com.test</groupId>
<artifactId>B</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
本文详细描述了一次在Spring框架中遇到的Bean冲突问题,由于两个模块中存在同名的Bean定义导致异常。通过排查,发现是模块间不恰当的依赖引入引起的冲突,并给出了删除多余依赖的解决方案。
2900

被折叠的 条评论
为什么被折叠?



