SpringBoot使用PageHelper报错

本文最后更新于:2 年前

SprinBoot与PageHelper的版本冲突导致项目启动失败。

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

***************************
APPLICATION FAILED TO START
***************************

Description:

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

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


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.


Process finished with exit code 1

分析

我是用的版本过低.

在SpringBoot2.6.4版本做项目的时间,中间用到了PageHelper做分页处理,引入依赖之后启动项目的时间报了上面的错误

1
2
3
4
5
6
<!-- Spring Boot pagehelper 依赖 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>

解决方法

升级版本

使用SpringBoot2.6及以上版本,对应的PageHelper版本应该在1.4.1及以上

1
2
3
4
5
6
<!-- Spring Boot pagehelper 依赖 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>