Mybatis分页插件开源工具PageHelper项目地址:https://github.com/pagehelper/Mybatis-PageHelper
与springboot集成分页:
添加POM依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
application.yml配置
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
方法代码:
PageHelper.startPage(pageNo, pageSize);
List<ServiceCategoryDo> serviceCategoryDoList = serviceCategoryDao.findCategoryList(record);
PageInfo<ServiceCategoryDo> pageInfo = new PageInfo<>(serviceCategoryDoList);