. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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