这句话的意思是:应用程序上下文中某些bean的依赖关系形成了一个循环
有时候在写项目时会忘记类的依赖关系,很容易导致两个对象互相注入,形成了一个循环,但是官方是不鼓励依赖循环,默认情况下禁止它们。
解决办法1Update your application to remove the dependency cycle between beans
更新应用程序以删除bean之间的依赖关系循环。一般控制台会打出来告诉你是哪里的类导致的互相依赖。比如以下日志:
The dependencies of some of the beans in the application context form a cycle: ┌─────┐ | springLoopService1 (field com.jiefei.jdbc.service.impl.SpringLoopService2 com.jiefei.jdbc.service.impl.SpringLoopService1.springLoopService2) ↑ ↓ | springLoopService2 (field com.jiefei.jdbc.service.impl.SpringLoopService1 com.jiefei.jdbc.service.impl.SpringLoopService2.springLoopService1) └─────┘
直接根据自己需要,让他们不要互相依赖就行了。
解决办法2在application.yml 中使用以下配置,好像是SpringBoot2.6.0之后默认禁止的。
spring:
main:
allow-circular-references: true #允许循环引用



