小白的springboot之路(十五)mybatis的PageHelper分页插件使用
Posted 大叔杨的园子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小白的springboot之路(十五)mybatis的PageHelper分页插件使用相关的知识,希望对你有一定的参考价值。
0、前言
用mybatis,那么分页必不可少,基本都是用PageHelper这个分页插件,好用方便;
1、实现
1.1、添加依赖:
<!-- 3、集成 mybatis pagehelper--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.10</version> </dependency>
1.2、配置文件增加配置项:
pagehelper.helper-dialect=mysql
1.3、使用:
int startPage= 2; int pageSize= 2; PageHelper.startPage(startPage, pageSize); PageHelper.orderBy("id ASC"); List<User> allUser = userservice.getAll(); return allUser ;
完毕,是不是很简单!
以上是关于小白的springboot之路(十五)mybatis的PageHelper分页插件使用的主要内容,如果未能解决你的问题,请参考以下文章
企业分布式微服务云SpringCloud SpringBoot mybatis (三十五)Restdoc生成api文档
企业分布式微服务云SpringCloud SpringBoot mybatis (二十五)集成swagger2构建Restful API
小记: Mybatis重拾之路(SpringBoot整合Mybatis)
企业分布式微服务云SpringCloud SpringBoot mybatis (十五)Spring Boot中使用Flyway来管理数据库版本