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
相关推荐
laocooon52385788610 小时前
写代码 调bug相关信息
bug
鸿儒51710 小时前
记录一个C++操作8位影像的一个bug
开发语言·c++·bug
·云扬·12 小时前
【Bug】 Elasticsearch启动失败(exit code 78):2个bootstrap检查问题排查与解决
elasticsearch·bootstrap·bug
BrianGriffin1 天前
get_download_file_path: command not found (asdf bug已解决)
bug
咸虾米_1 天前
解决九两酒商城[uni-pay-co]: Error:执行失败,积 分需要大于等于1的bug
bug·unicloud云开发·微信小程序商城·uniapp项目
凯子坚持 c1 天前
Git分支实战指南:如何优雅地管理版本、修复Bug并解决合并冲突
git·bug
北冥有渔jy1 天前
BT6.0常见的BUG
网络·安全·bug·蓝牙
测试19982 天前
一个只能通过压测发现Bug
自动化测试·软件测试·python·selenium·测试工具·bug·压力测试
狂奔的sherry2 天前
网卡获取模组ip失败问题解析
bug
nnsix3 天前
Unity ReferenceFinder插件 多选资源查找bug解决
unity·游戏引擎·bug