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

介绍

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

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

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

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

目录

问题描述:

解决方法:

加注解

 在SpringBoot里面加配置

第一种:

第二种: 


问题描述:

SpringBoot启动报错

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注解进行自动装配

 在SpringBoot里面加配置

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

第一种:

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

第二种: 

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

    }

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

猜你喜欢

转载自blog.csdn.net/weixin_60387745/article/details/129921488