spring高版本循环依赖报错问题
1 2 3 4 | 在application.yml放在spring下面 main: allow-bean-definition-overriding: true allow-circular-references: true |
12.6
.
0
后关闭了循环引用,需要开启报错信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '*****.BasicCompanyFourInfoController':
Unsatisfied dependency expressed through field 'loginFacade'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name '*****.protection.application.service.impl.LoginFacadeImpl': Unsatisfied dependency expressed through field 'checkTaskService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '*****.protection.domain.operation.impl.CheckTaskServiceImpl':
Unsatisfied dependency expressed through field 'checkPlanService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name '*****.protection.domain.operation.impl.CheckPlanServiceImpl': Unsatisfied dependency expressed through field 'checkTaskService';
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name '*****.protection.domain.operation.impl.CheckTaskServiceImpl':
Requested bean is currently in creation: Is there an unresolvable circular reference?
然后spring提示:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
大概意思就是:不鼓励依赖循环引用,默认情况下禁止使用循环引用。想要开启就设置下所以设置上面的就好了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!