我是靠谱客的博主 热心花卷,最近开发中收集的这篇文章主要介绍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

最后

以上就是热心花卷为你收集整理的SpringBoot 升级到 v2.6.3 后启动失败,报循环引用的错误错误原因解决方案的全部内容,希望文章能够帮你解决SpringBoot 升级到 v2.6.3 后启动失败,报循环引用的错误错误原因解决方案所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部