springboot+mybatis使用分页插件pageHelper
2019-07-01 11:56
597 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/shuaigg001/article/details/94385572
springboot+mybatis使用分页插件pageHelper
1.pom.xml文件添加依赖
<!-- springboot分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.3</version> </dependency>
注意版本问题,如果出现不能使用可以更换版本使用。我的springboot使用的是2.0.5,使用正常
2.application.yml配置(可以不配置,使用默认配置)
pagehelper: # dialect: ① # 分页插件会自动检测当前的数据库链接,自动选择合适的分页方式(可以不设置) helper-dialect: mysql # 上面数据库设置后,下面的设置为true不会改变上面的结果(默认为true) auto-dialect: true page-size-zero: false # ② reasonable: true # ③ # 默认值为 false,该参数对使用 RowBounds 作为分页参数时有效。(一般用不着) offset-as-page-num: false # 默认值为 false,RowBounds是否进行count查询(一般用不着) row-bounds-with-count: false #params: ④ #support-methods-arguments: 和params配合使用,具体可以看下面的讲解 # 默认值为 false。设置为 true 时,允许在运行时根据多数据源自动识别对应方言的分页 auto-runtime-dialect: false # ⑤ # 与auto-runtime-dialect配合使用 close-conn: true # 用于控制默认不带 count 查询的方法中,是否执行 count 查询,这里设置为true后,total会为-1 default-count: false #dialect-alias: ⑥
3.在代码中使用
//就很精简的一行代码 //PageHelper.startPage(pageNumber, pageSize) //在这行代码后的第一条查询语句自动分页 Page<Object> page = PageHelper.startPage(1, 5); //分页 amzSellerSkuList = searchDataByAsinAndUserIdMapper.findCodingByAsin(buCategoryModelNumberAsin.getAsinId()); //不分页 List<UserPermissionRel> userPermissionRelList = userPermissionRelMapper.findAllByUserId(userId); map.put("total", page.getTotal()); //获得总条数 map.put("pageNumber", page.getPageNum());//当前页 map.put("pageSize", page.getPageSize());//查询条数
相关文章推荐
- Spring Boot系列教程十一: Mybatis使用分页插件PageHelper
- springboot2.0.5集成mybatis(PageHelper分页插件、generator插件使用)
- 记录问题:springboot中使用Mybatis-pagehelper分页插件遇到的版本兼容问题
- springboot整合mybatis和pageHelper分页插件
- spring-boot 集成mybatis的分页插件PageHelper版本问题
- Maven+Spring + Mybatis 使用 PageHelper 插件分页
- Spring + Mybatis 使用 PageHelper 插件分页
- SpringBoot Mybatis PageHelper分页插件的两种用法(二)
- Spring + Mybatis 使用 PageHelper 插件分页
- Spring + Mybatis 使用 PageHelper 插件分页
- springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件
- Spring,SpringBoot 集成 MyBatis 的分页插件 PageHelper
- springboot如何集成mybatis的pagehelper分页插件
- spring-boot 集成mybatis的分页插件PageHelper和Generator (番外)
- Spring Boot整合Mybatis-Plus和PageHelper分页插件,附项目源码
- springboot中分页插件pageHelper的使用
- springboot整合mybatis之分页插件pagehelper
- spring-boot 集成mybatis的分页插件PageHelper和Generator (番外)
- Mybatis分页插件 - PageHelper与springBoot的整合
- springboot+Mybatis的分页插件pageHelper