1.在pom.xml中引入依赖:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<!--分页插件-->
2.在application.propreties加入配置:
pagehelper.helperDialect=mysql pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
3.在controller层中应用
@GetMapping(value="getListByMap")
public List<ZhuanyeInfo> getListByMap (
@RequestParam(value="currentPage",required=false,defaultValue="1")Integer currentPage,
@RequestParam(value="pageSize",required=false,defaultValue="10")Integer pageSize
) throws ParseException {
PageHelper.startPage(currentPage , pageSize);
List<ZhuanyeInfo> list = zhuanyeService.getListByMap(map);
PageInfo<ZhuanyeInfo> pageList = new PageInfo<ZhuanyeInfo>(list);
List<ZhuanyeInfo> datas = pageList.getList();
return datas;
}