91名师指路-头部
91名师指路

This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the

由于某些原因,现在不支持支付宝支付,如需要购买源码请加博主微信进行购买,微信号:13248254750

场景:我是在一个serviceA 里面调用了serviceB 里面的方法,然后我又在serviceB里面调用了serviceA里面的方法,报错信息如下:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'expandAlgorithmController': 
Unsatisfied dependency expressed through field 'expandAlgorithmService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'expandAlgorithmServiceImpl': Bean with name 'expandAlgorithmServiceImpl' has been injected into other beans [businessExpandServiceImpl]
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.


错误原因:serviceA和serviceB循环依赖了,spring在初始化bean的时候就不知道先初始化哪个bean就会报错。

解决方法:在注入service的时候加一个@Lazy 注解就可以了。


参考资料:https://blog.csdn.net/u011546347/article/details/85230362


2021-02-02 18:12:41     阅读(3103)

名师出品,必属精品    https://www.91mszl.com

联系博主    
用户登录遮罩层
x

账号登录

91名师指路-底部