1 添加pom依赖
<!-- SpringBoot/MyBatis使用PageHelper分页控件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
2 修改application.properties文件
#pagehelper分页插件配置
pagehelper.helperDialect=mysql
3 修改业务代码
//设置分页数据
PageHelper.startPage(pageNum, pageSize);
List<XinWen> XinWenS =xinwenService.getxinwenList();
//封装了数据列表和分页的信息
PageInfo<XinWen> XinWenPageInfo = new PageInfo<>(XinWenS);
return XinWenPageInfo;