问题描述:The dependencies of some of the beans in the application context form a cycle: ┌──->──┐ | com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration
意思是依赖相互循环了,没办法启动
解决办法(三选一即可,实在不行你再全部试一遍吧)
-
排除 PageHelperAutoConfiguration: 您可以在 Spring Boot 的启动类上使用
@SpringBootApplication(exclude = {PageHelperAutoConfiguration.class})
注解,从而排除PageHelperAutoConfiguration
自动配置类,防止其参与自动配置过程。
@SpringBootApplication(exclude = {PageHelperAutoConfiguration.class})
2.手动配置 PageHelper: 您也可以考虑手动配置 PageHelper,而不使用自动配置。创建一个配置类,并在其中手动配置 PageHelper 的相关属性。下面是一个示例,展示如何手动配置 PageHelper
@Configuration
public class MyPageHelperConfig {
@Bean
public PageHelper pageHelper() {
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
// 配置 PageHelper 属性
properties.setProperty("offsetAsPageNum", "true");
properties.setProperty("rowBoundsWithCount", "true");
properties.setProperty("reasonable", "true");
pageHelper.setProperties(properties);
return pageHelper;
}
}
在这个示例中,您可以根据实际需求配置 PageHelper 的属性。然后,在您的 Spring Boot 应用程序中引入这个配置类。
第一个方法我就成功了,第二个方法我还没有尝试,感兴趣的同学可以自己尝试以下
3.可以在application.yml里配置一个允许循环依赖:
spring:
main:
allow-circular-references: true
第三个方法应该很方便