循环依赖 in its raw version as part of a circular reference

本文讨论了在Spring中遇到的循环依赖问题,具体表现为在AService和BService之间出现互相注入,导致在服务器部署时抛出UnsatisfiedDependencyException。错误信息表明在bean的创建过程中,由于循环引用,某些bean被注入了未完成初始化的版本。解决办法是在@Autowired注解上添加@Lazy注解来避免立即初始化。
摘要由CSDN通过智能技术生成

两个实现层,然后相互注入对方(AService、BService)

在AService 注入 BService

在BService 注入AService

出现循环依赖问题具体错误如下

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'advanceAmountController': Unsatisfied dependency expressed through method 'setAdvanceAmountService' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'advanceAmountService': Unsatisfied dependency expressed through method 'setAsyncService' parameter 0; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'asyncService': Bean with name 'asyncService' has been injected into other beans [orgService,resourceService] 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. T

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值