Springboot循环依赖问题: Bean with name ‘xxxxService‘ has been injected into other beans

Error creating bean with name 'xxxxService': Bean with name 'xxxxService' has been injected into other beans [.....] 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.

查找好久,都说是循环依赖的问题,我就在想:但是springboot不是自己解决的循环依赖的问题了吗?一直找不到原因,直到看了https://blog.csdn.net/dx125806/article/details/50128837这篇帖子下一个老哥的评论:

ben_harden: spring默认是支持循环依赖,allowCircularRefrence默认为true。
也可以手动设置applicationContext.setAllowCircularReferences(false); 
产生这个问题原因:in its raw version as part of a circular reference, but has eventually been wrapped.
应该是项目中对某个类进行了wrapped,可能是开启异步导致

最后发现是在xxxservice中添加了@Async的注解导致的。

最后再附上搜索到的一篇为什么会出现这种情况的博客:https://www.jb51.net/article/185794.htm

你可能感兴趣的:(bug,spring,boot,spring,java)