记一次循环依赖的异常分析its raw version as part of a circular reference,but not use the final version of the bea

org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'publicAccountInfoServiceImpl':Injection of resource dependencies failed; nested exception is 
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name
 'publicAccountInfoDao': Bean with name 'publicAccountInfoDao' has been injected into other beans 
 [publicAccountService] 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
 overeager type matching - consider using 'getBeanNamesForType' with the 'allowEagerInit' flag turned off

异常大概如上。
然后我们先说一下什么是依赖循环,比如:我现在有一个ServiceA需要调用ServiceB的方法,那么ServiceA就依赖于ServiceB,那在ServiceB中再调用ServiceA的方法,就形成了循环依赖。Spring在初始化bean的时候就不知道先初始化哪个bean就会报错。
看了上述是不是觉得很简单呢?但是呢,我的代码并不是如此,出现问题的地方有两个PublicAccountInfoServiceImplPublicAccountService,这两个类都注入了PublicAccountInfoDaoPublicAccountInfoDao这个类只与数据库交互,并没有引入上面两个类,所以并非上述所谓的依赖循环。

@Service
public class PublicAccountInfoServiceImpl {
	@Resource
	priavte PublicAccountInfoDao publicAccountInfoDao;
} 
@Service
public class PublicAccountService{
	@Autowried
	priavte PublicAccountInfoDao publicAccountInfoDao;
} 

这些是上述两个类的部分代码,然而这些代码呢,也是很早之前的代码了。并不是笔者写的,这就问题很大,不知道怎么下手解决,然后我在注入PublicAccountInfoDao上面打上了@Lazy的注解就没问题了。暂时不知道原因,正在研究~~~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值