欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

springboot系列十五、springboot集成PageHelper

发布时间:2025/3/15 编程问答 47 豆豆
生活随笔 收集整理的这篇文章主要介绍了 springboot系列十五、springboot集成PageHelper 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

一、介绍

项目中经常会遇到分页,PageHelper为我们解决了这个问题。本质上实现了Mybatis的拦截器,作了分页处理。

二、配置PageHelper

1、引入依赖

pagehelper-spring-boot-starter对了pagehelper做了封装,减少 了配置文件,只需要在yml添加就能使用。

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.2.3</version> </dependency>

2、配置yml

pagehelper:helperDialect: mysqlreasonable: true #开启优化,<1页返回第一页supportMethodsArguments: true #是否支持接口参数来传递分页参数,默认falsepageSizeZero: false #pageSize=0 返回所有params: count=countSql

3、使用示例

@Testpublic void getAllUserByPage(){PageHelper.startPage(1,2);System.out.println(userDao.findAll());}

 

转载于:https://www.cnblogs.com/wangzhuxing/p/10203145.html

总结

以上是生活随笔为你收集整理的springboot系列十五、springboot集成PageHelper的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。