目录
1.遇到的问题
异常信息:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'ocpxAsyncCServiceImpl': Bean with name 'ocpxAsyncCServiceImpl' has been injected into other beans [ocpxCustomerService] 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.
这段日志是在说什么呢?它告诉我们什么问题呢?
在网上搜索了一下,找到了这个问题具体原因,分析的挺清楚,有兴趣的朋友可以看看
https://www.jb51.net/article/185794.htm
解决Bean with name ‘XX‘ has been injected into other beans 问题_鲁不迅的专栏-CSDN博客
2.解决思路
3.解决方案
4.具体方法
两个方法:
1、解耦。把相关的引用方法进行拆分,然后再进行二次开发,搞定这个事情就可以了。
这个方法在忙的时候根本实现不了,那就用另外一个方法。
2、使用注解@Lazy
就是使用懒加载,不在刚开始初始化的时候就创建对应的Bean。这样就可以避免这个问题。
总结:
我选择第二种方法,因为他比较简单