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
相关推荐
wy3136228214 小时前
android——开发中的常见Bug汇总与解决方案(闪退)
android·bug
Swift社区1 天前
RN 项目中“页面存在 ≠ 页面可见”会导致哪些隐藏 Bug?
react native·bug·react
tongyue1 天前
天问esp32驱动DHT11官方程序BUG修复
bug
laocooon5238578863 天前
写代码 调bug相关信息
bug
鸿儒5173 天前
记录一个C++操作8位影像的一个bug
开发语言·c++·bug
·云扬·3 天前
【Bug】 Elasticsearch启动失败(exit code 78):2个bootstrap检查问题排查与解决
elasticsearch·bootstrap·bug
BrianGriffin4 天前
get_download_file_path: command not found (asdf bug已解决)
bug
咸虾米_4 天前
解决九两酒商城[uni-pay-co]: Error:执行失败,积 分需要大于等于1的bug
bug·unicloud云开发·微信小程序商城·uniapp项目
凯子坚持 c4 天前
Git分支实战指南:如何优雅地管理版本、修复Bug并解决合并冲突
git·bug
北冥有渔jy4 天前
BT6.0常见的BUG
网络·安全·bug·蓝牙