1.引入依赖
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.0</version>
</dependency>
2.在application.yml中做如下配置
# 分页配置
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
3.在代码中使用
PageHelper.startPage(pageNum,pageSize);//这行是重点,表示从pageNum页开始,每页pageSize条数据
List<Tools> list = toolsMapper.findAll();
PageInfo<Tools> pageInfo = new PageInfo<Tools>(list);
return ServerResponse.createBySuccess("查询成功",pageInfo);