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
相关推荐
万粉变现经纪人2 小时前
如何解决 pip install cx_Oracle 报错 未找到 Oracle Instant Client 问题
数据库·python·mysql·oracle·pycharm·bug·pip
ChoSeitaku1 天前
Git分支|创建分支|切换分支|合并分支|删除分支|合并冲突分支|分支策略|bug分支|强制删除分支
bug
Lxinccode2 天前
BUG(23) : node版claude code启动报错Failed to connect to api.anthropic.com: ETIMEDOUT
bug·claude·claude启动报错
buyulian2 天前
Bug防御体系:技术方案的优与劣
java·经验分享·bug·软件工程
川石课堂软件测试3 天前
接口测试需要注意的一些BUG
网络·数据库·python·单元测试·bug·压力测试·tornado
深念Y3 天前
记一个BUG:Trae里MongoDB和MySQL MCP不能共存
数据库·mysql·mongodb·ai·bug·agent·mcp
测试_AI_一辰4 天前
AI系统测试实践:Tool执行与状态管理(Agent系统最容易出Bug的地方)
人工智能·ai·自动化·bug·ai编程
飞Link5 天前
告别盲目找Bug:深度解析 TSTD 异常检测中的预测模型(Python 实战版)
开发语言·python·算法·bug
小同志006 天前
软件测试周期 与 BUG
java·软件测试·bug·软件测试周期·bug等级
Reisentyan6 天前
edge的神秘搜索栏 暗广 bug
bug