解决pom.xml依赖循环的问题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: ┌──->──┐ | com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration

意思是依赖相互循环了,没办法启动

解决办法(三选一即可,实在不行你再全部试一遍吧)

  1. 排除 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

第三个方法应该很方便

  • 11
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值