【BUG】Requested bean is currently in creation: Is there an unresolvable circular reference?

项目场景:

某项目引用其他starter内 Util 工具类


问题描述

项目A启动没有问题;项目B引用starter抛出工具类抛出异常:

Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘billController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘billServiceImpl’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘driverBillListQryExe’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘tmsDataScopeThreadLocalUtil’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘tmsDataScopeTools’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userTools’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.base.starter.redis.config.MFStartRedisSimpleConfig’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MFCacheManagerConfig’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘mfRedisTemplate’: Requested bean is currently in creation: Is there an unresolvable circular reference?

翻译:所需的bean目前正在创建中:是否存在不可解析的循环引用?


原因分析:

1,项目A引入没问题,项目B有问题,大概率不是starter自身的问题;
2,没有扫包? 并不是
3.检查项目A和项目B在使用上有什么区别, 完全一致


解决方案:

经过3h的查找,最后发现还是扫包的问题;虽然scan了所需的package,但是顺序有问题,
如下,最后scan的"com.component"

@SpringBootApplication(scanBasePackages = {
        "com.***",
        "com.***",
        "com.***",
        "com.***",
        "com.component",
})

顺序更改一下问题解决,成功启动

@SpringBootApplication(scanBasePackages = {
		"com.component",
        "com.***",
        "com.***",
        "com.***",
})

Requested bean is currently in creation: Is there an unresolvable circular reference?
说明bean的加载顺序有问题

在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值