【SpringBoot已解决】SpringBoot启动报错The dependencies of some of the beans in the application context

£神魔★判官ぃ 2024-03-24 13:40 195阅读 0赞

介绍

这里是小编成长之路的历程,也是小编的学习之路。希望和各位大佬们一起成长!

以下为小编最喜欢的两句话:

要有最朴素的生活和最遥远的梦想,即使明天天寒地冻,山高水远,路远马亡。

一个人为什么要努力? 我见过最好的答案就是:因为我喜欢的东西都很贵,我想去的地方都很远,我爱的人超完美。因此,小编想说:共勉!

目录

问题描述:

解决方法:

加注解

在SpringBoot里面加配置

第一种:

第二种:


问题描述:

SpringBoot启动报错

265c41c6ced14bf8aa4d3ce104e0b89b.png

Description:

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

┌──->──┐
| com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration
└──<-──┘

bean循环依赖的问题

Action:

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.allow-circular-references设置为true来自动打破循环。

解决方法:

加注解

在所有需要自动装配bean的地方,加一个@Autowried注解进行自动装配

e919f8af21b9451b94e397d6034b0b4b.png

在SpringBoot里面加配置

上面的报错信息已经提示我们,需要加入以下代码来打破循环

第一种:

  1. # 允许循环依赖
  2. spring.main.allow-circular-references = true

#

febc69d091ed4ea582701a95b8861ff8.png

第二种:

  1. public static void main(String[] args) {
  2. new SpringApplicationBuilder(你的启动类名.class).allowCircularReferences(true).run(args);
  3. }

0f5cb99de58c4c4e8229f7380f7222df.png

以上就是小编错误解决的方式,希望各位大佬能够多多指教!!!

发表评论

表情:
评论列表 (有 0 条评论,195人围观)

还没有评论,来说两句吧...

相关阅读