1-在pom.xml中引入依賴
自己可以去maven使用最新版本
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
2.在application.yml中做如下配置
# 分頁配置
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
3.在代碼中使用
PageHelper.startPage(10, 30);
List<Map<String, Object>> list= mapper.infoList(params);
PageInfo pageInfo = new PageInfo(list);
4.最後返回的PageInfo信息