啓動項目,經過@Autowired注入對象,出現循環依賴,致使項目啓動失敗,具體報錯信息以下: html
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,因此就會出現這種狀況spring
參考:https://www.cnblogs.com/leng39/p/9530569.htmlexpress