Spring Boot 整合Pagehelper(为什么PageHelper分页不生效)
第一步引用依赖maven方式引入<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><
文章共298字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
第一步
引用依赖
maven方式引入
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
gradle方式引入
compile 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.5'
第二步
推荐Services层引入分页
public PageInfo<Order> findOrderList(int pageNum, int pageSize, OrderVO orderVO) {
//使用分页插件,核心代码就这一行
PageHelper.startPage(pageNum, pageSize);
List<Order> list = orderMapper.findOrderList(orderVO);
PageInfo<Order> pageInfo = new PageInfo<>(list);
return pageInfo;
}
这里就不写Controller层代码了
其实很简单,楼主在这里最开始耽误了些时间,因为包引入错误导致始终无法进行分页
误区
只引入了分页插件,
compile 'com.github.pagehelper:pagehelper:5.0.3'
和引入Spring Boot Start库它俩的区别就是会多出两个依赖包,如果单引入pagehelper可能需要自己手动做配置过滤器
更多推荐
已为社区贡献1条内容
所有评论(0)