the dependencies of some of the beans in the application context form a cycle

前些天在项目发布启动中遇到这个“the dependencies of some of the beans in the application context form a cycle”问题
the dependencies of some of the beans in the application context form a cycle_第1张图片
由字面意思就知道是由于代码中存在着循环依赖导致的,于是我便在代码中查找到底哪些注入互相引用了,有时代码之间依赖太复杂,人工查找的话太耗费时力,使用idea的话就很容易能查找到,我简单说一下在idea中怎样查找是否有相互依赖。

选择报循环依赖的地方右键选择diagrams
the dependencies of some of the beans in the application context form a cycle_第2张图片

接着
the dependencies of some of the beans in the application context form a cycle_第3张图片

然后就可以看到你文件夹下所有的类
the dependencies of some of the beans in the application context form a cycle_第4张图片

右键选择Show Dependencis
the dependencies of some of the beans in the application context form a cycle_第5张图片

就可以查看到所有类依赖的情况,我这里就能清楚的看出哪里相互引用了
the dependencies of some of the beans in the application context form a cycle_第6张图片

清除其中一个依赖后问题解决
the dependencies of some of the beans in the application context form a cycle_第7张图片

你可能感兴趣的:(java基础,spring,开发工具)