Bean with name 'ivrNodeInfoServiceImpl' has been injected into other beans [ivrFlowInfoServiceImpl] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example.
时间: 2024-04-26 20:22:13 浏览: 237
Spring循环依赖报错Bean with name ‘**’ has been injected into other beans [**] in its raw version as part
5星 · 资源好评率100%
这个错误是由于循环依赖引起的。具体来说,当两个或多个bean相互依赖时,会出现循环依赖的情况,这通常会导致Spring容器无法完成依赖注入。在你的情况下,'ivrNodeInfoServiceImpl'被注入到'ivrFlowInfoServiceImpl'中,而'ivrFlowInfoServiceImpl'又被注入到'ivrNodeInfoServiceImpl'中,导致循环依赖。
为了解决这个问题,你可以使用Spring的构造函数依赖注入,而不是使用属性注入。构造函数注入可以避免循环依赖问题,因为所有的bean都会在实例化时一次性注入其依赖项。另外,你也可以使用@Lazy注解,将依赖的bean延迟加载,以避免循环依赖问题。最后,你也可以使用"getBeanNamesForType"方法来查找所有依赖,以便更好地管理依赖关系。
阅读全文