SpringBoot:循环引用解决方式
1 前言
SpringBoot启动时提示循环引用:
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.
it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.,即可以通过将spring.main.allow-circular-references设置为true来自动中断循环。
2 使用
解决方式即在application.properties配置文件下,增加如下配置即可:
spring.main.allow-circular-references = true

当SpringBoot遇到循环引用问题时,可以设置`spring.main.allow-circular-references=true`来允许这种引用。在`application.properties`中添加此配置,可以自动中断循环依赖。
6723

被折叠的 条评论
为什么被折叠?



