這篇文章給大家介紹mybatis中如何使用pagehelper插件,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
1.添加插件的依賴
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.0.4</version></dependency><dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-autoconfigure</artifactId> <version>1.2.5</version></dependency><dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.5</version></dependency>
2.添加配置文件
pagehelper.helper-dialect=mysqlpagehelper.params=count=countSqlpagehelper.reasonable=truepagehelper.support-methods-arguments=true
3.新建測試類測試
@GetMapping("/list")@ResponseBodypublic PageInfo<User>getUserList(){//分頁起始也頁數(shù)和條數(shù) PageHelper.startPage(0,5);//調(diào)用查詢方法,此時的查詢方法已經(jīng)是分頁返回的數(shù)據(jù) List<User> list=userService.selectAll();//封裝分頁參數(shù)返回給前臺PageInfo pageInfo = new PageInfo(list);return pageInfo;}
如果失效,可以在pom里面添加aop依賴在試
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId></dependency>
關(guān)于mybatis中如何使用pagehelper插件就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
標(biāo)題名稱:mybatis中如何使用pagehelper插件-創(chuàng)新互聯(lián)
路徑分享:http://vcdvsql.cn/article4/jejie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站排名、響應(yīng)式網(wǎng)站、品牌網(wǎng)站建設(shè)、網(wǎng)站內(nèi)鏈、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)