我是靠谱客的博主 迷路小伙,这篇文章主要介绍MyBatis 之SpringBoot2.0集成分页插件pagehelper-spring-boot-starter添加pom依赖添加配置(根据自己情况选择)代码中使用插件进行分页,现在分享给大家,希望可以做个参考。
文章目录
- 添加pom依赖
- 添加配置(根据自己情况选择)
- 代码中使用插件进行分页
添加pom依赖
pagehelper封装的springboot启动依赖默认加入了mybatis的springboot启动依赖,如果项目中用到了mybatis启动依赖,可以选择将原有的依赖删除,或者在pagehelper依赖中排除mybatis的启动依赖。
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13<version>
</dependency>
// 或者
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13<version>
<exclusions>
<exclusion>
<artifactId>mybatis-spring-boot-starter</artifactId>
<groupId>org.mybatis.spring.boot</groupId>
</exclusion>
</exclusions>
</dependency>
添加配置(根据自己情况选择)
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
代码中使用插件进行分页
PageInfo<Object> pageInfo = PageHelper
.startPage(2, 5)
.doSelectPageInfo(() -> psbcDiscountQualificationMapper.findAll());
PageHelper.count(() -> psbcDiscountQualificationMapper.findAll());
最后
以上就是迷路小伙最近收集整理的关于MyBatis 之SpringBoot2.0集成分页插件pagehelper-spring-boot-starter添加pom依赖添加配置(根据自己情况选择)代码中使用插件进行分页的全部内容,更多相关MyBatis内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复