1.pom.xml添加以下依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.0</version>
</dependency>
2.properties配置文件添加如下(连接mysql)
#pagehelper
pagehelper.helper-dialect=mysql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true
pagehelper.params=countSql
3.mapper语句执行前开启分页,之后可以用PageInfo
PageHelper.startPage(pageNum, pageSize);
List<Directory> drs = directoryService.selectDirectoryByExtNo(extno);
PageInfo<Directory> pageInfo = new PageInfo<Directory>(drs);
return new Result(200, pageInfo.getList(), pageInfo.getTotal());