springboot系列十五、springboot集成PageHelper
生活随笔
收集整理的這篇文章主要介紹了
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=countSql3、使用示例
@Testpublic void getAllUserByPage(){PageHelper.startPage(1,2);System.out.println(userDao.findAll());}?
轉載于:https://www.cnblogs.com/wangzhuxing/p/10203145.html
總結
以上是生活随笔為你收集整理的springboot系列十五、springboot集成PageHelper的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IDEA配置tomcat部署web项目时
- 下一篇: axios get post下载文件