Bean with name 'xxxService' has been injected into other beans [xxxServiceA,xxxServiceB] in its raw version as part of a circular reference, but has eventually been wrapped


 

啟動項目,通過@Autowired注入對象,出現循環依賴,導致項目啟動失敗,具體報錯信息如下: 

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxtController': 
Unsatisfied dependency expressed through field 'xxxService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: 
Error creating bean with name 'xxxService': Bean with name 'xxxService' has been injected into other beans [xxxServiceA,xxxServiceB] 
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 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off

  

Bean with name 'xxxService' has been injected into other beans [xxxServiceA,xxxServiceB] in its raw version as part of a circular reference, but has eventually been wrapped
翻譯:xxxService 這個bean已經被注入到xxxServiceA、xxxServiceB這兩個bean中了,他們之間存在循環引用(依賴),也就是說:xxxServiceA中注入了xxxService,而xxxService中也要注入xxxServiceA,所以就會出現這種情況

 

參考:https://www.cnblogs.com/leng39/p/9530569.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM