首先引入mybatis分页插件 pageHelper
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
其次配置application.yml文件
# mybatis 分页
# 设置数据库类型
pagehelper.helper-dialect=mysql
#开启合理化:页码<=0 查询第一页,页码>=总页数查询最后一页
pagehelper.reasonable=true
#支持通过 Mapper 接口参数来传递分页参数
pagehelper.support-methods-arguments=true
# 参数 成员变量 = ${xx}
pagehelper.params=count=countSql
最后传值页数页码来获取分页数据
执行后可以查看到具体数据