0
点赞
收藏
分享

微信扫一扫

Relying upon circular references is discouraged and they are prohibited by default.


Relying upon circular references is discouraged and they are prohibited by default.

创建springboot项目时,使用的版本是2.7.13,运行项目时报错

Relying upon circular references is discouraged and they are prohibited by default._java

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.

直接翻译过来的话就是:

不鼓励依赖循环引用,并且默认情况下禁止循环引用。更新应用程序以删除bean之间的依赖循环。作为最后的手段,可以通过设置spring.main来自动打破这个循环。允许循环引用为true。

Relying upon circular references is discouraged and they are prohibited by default._java_02

解决方案

提示中已经把解决方案说了 setting spring.main.allow-circular-references to true.

在springboot2.6正式发布,循环依赖默认静止了。我们只需要开启就行

如果是 properties 配置文件

spring.main.allow-circular-references=true

如果是 yml 配置文件

spring:
  main:
    allow-circular-references:true

我这里是 yml配置,加上后重启就正常运行了

Relying upon circular references is discouraged and they are prohibited by default._ci_03


举报
0 条评论