SpringBoot 升级到 v2.6.3 后启动失败,报循环引用的错误


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.3)

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-23 21:21:44.189 | ERROR | TID: N/A | main | org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

   adminApiController (field com.quec.cloud.binding.service.BindService com.quec.cloud.binding.controller.admin.AdminApiController.bindService)
┌─────┐
|  bindService (field com.quec.cloud.binding.service.ShareService com.quec.cloud.binding.service.BindService.shareService)
↑     ↓
|  shareService (field com.quec.cloud.binding.service.BindModeService com.quec.cloud.binding.service.ShareService.bindModeService)
↑     ↓
|  bindModeService (field com.quec.cloud.binding.service.BindService com.quec.cloud.binding.service.BindModeService.bindService)
└─────┘


Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.

Disconnected from the target VM, address: '127.0.0.1:1976', transport: 'socket'

Process finished with exit code 1

错误原因

SpringBoot v2.6.3 中,做了循环应用的检查,默认情况下,如果类中存在有循环引用的情况,就会报上面的错误。

解决方案

在 Spring 的配置文件中主动关闭循环引用的检查:

spring.main.allow-circular-references 设置为 true

spring:
  main:
    allow-circular-references: true

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值