Bean with name '' has been injected into other beans [] in its raw version as part of a circular

1、报错信息

Unsatisfied dependency expressed through field 'xxxService';
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: 
Error creating bean with name 'xxxServiceImpl': 
Bean with name 'xxxServiceImpl' has been injected into other beans [yyyServiceImpl] 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, for example.

2、错误原因:

xxxService 类中注入了 yyyService , 而在 yyyService 类中也注入了 xxxService 

3、解决方式:

 xxxService 类注入 yyyService 时,增加注解@Lazy,反之同理。

注意:

尽量不要导致循环依赖。

posted @ 2021-08-05 18:07  唏嘘-  阅读(2412)  评论(0编辑  收藏  举报