The bean ‘xxxxx‘, defined in class path resource [XXXXXXX]依赖定义冲突异常

本质上就是导入的依赖中出现了重名,ioc进行注入的时候会根据名字来,这样的话就会遭成依赖冲突,我的错误是
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'connectionManager' defined in class path resource [org/springframework/cloud/openfeign/clientconfig/HttpClientFeignConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.openfeign.clientconfig.HttpClientFeignConfiguration; factoryMethodName=connectionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/openfeign/clientconfig/HttpClientFeignConfiguration.class]] for bean 'connectionManager': There is already [Generic bean: class [com.github.tobato.fastdfs.domain.conn.ConnectionManager]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/D:/Apps/Learn/Maven3.8.8/apache-maven-3.8.8/repository/com/github/tobato/fastdfs-client/1.26.5/fastdfs-client-1.26.5

这个错误信息表明在Spring容器中存在名为connectionManager的bean定义冲突。具体来说,错误信息中提到了在HttpClientFeignConfiguration类中定义了名为connectionManager的bean,而在其他位置(fastdfs-client-1.26.5.jar中)也存在相同名称的connectionManager的bean。

解决方法:

配置文件添加

YAML 复制代码
#yaml 这里演示格式
spring: 
   main:
    allow-bean-definition-overriding: true
相关推荐
Tatakai251 小时前
Mybatis Plus分页查询返回total为0问题
java·spring·bug·mybatis
鸽芷咕8 小时前
【Python报错已解决】libpng warning: iccp: known incorrect sRGB profile
开发语言·python·机器学习·bug
鸽芷咕12 小时前
【Python报错已解决】ModuleNotFoundError: No module named ‘paddle‘
开发语言·python·机器学习·bug·paddle
腾飞的信仰2 天前
如何快速解决程序中的BUG
bug
Everglowwwwww2 天前
【bug】通过lora方式微调sdxl inpainting踩坑
学习·计算机视觉·ai作画·stable diffusion·bug
数据最前线2 天前
创建索引遇到这个Bug,19c中还没有修复
oracle·bug
CV金科3 天前
蓝桥杯-STM32G431RBT6(UART解析字符串sscanf和解决串口BUG)
c语言·stm32·单片机·嵌入式硬件·mcu·算法·bug
DisonTangor3 天前
网传阿里云盘出现bug,可看到其他用户云盘图片
阿里云·bug
后端小张3 天前
System.out源码解读——err 和 out 一起用导致的顺序异常Bug
java·开发语言·jdk·bug
我又来搬代码了3 天前
【Android】【Bug】Activity全屏(保留底部按钮)被打断变成非全屏了
android·bug