Spring 高版本循环依赖问题:
问题描述
提示:Spring boot 应用启动报错
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.
原因分析:
提示:Spring boot 2.6 版本之后默认禁止循环依赖
![](https://img-blog.csdnimg.cn/58b11347cf334b8ebbc7469f10065acc.png)
解决方案:
提示:消除循环依赖(公共服务没有抽取)、开启循环依赖
1 方法一: 找到循环依赖的代码用其他方式代替,抽取公共的Service
2 方法二:spring.main.allow-circular-references=true