PageHelper是什么?
PageHelper是MyBatis开源的物理分页插件,只需要使用PageHelper.startPage(pageNum, pageSize)这一行代码接口完成分页查询。
MyBatis分页插件PageHelper官方文档
PaginationInnerInterceptor是什么?
PaginationInnerInterceptor是MyBatis-Plus内置的分页插件。
什么是 MyBatis-Plus?
SpringBoot - MyBatis-Plus - 基于PaginationInnerInterceptor的分页查询(三)
如何整合PageHelper?
1. 添加依赖
在POM.XML中添加以下依赖:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>最新版本</version>
</dependency>
2. 修改配置
在application.yml中添加以下配置:
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
3. 代码编写
// 在controller中使用以下代码完成分页:
PageHelper.startPage(1, 10);
List<User> list = userMapper.selectAll(1);