欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mybatis使用pagehelper插件過程詳解

 更新時(shí)間:2019年12月19日 14:23:55   作者:一步一高  
這篇文章主要介紹了mybatis使用pagehelper插件過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了mybatis使用pagehelper插件過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

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=mysql
pagehelper.params=count=countSql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true

3.新建測(cè)試類測(cè)試

@GetMapping("/list")
@ResponseBody
public PageInfo<User>getUserList(){
//分頁起始也頁數(shù)和條數(shù)
 PageHelper.startPage(0,5);
//調(diào)用查詢方法,此時(shí)的查詢方法已經(jīng)是分頁返回的數(shù)據(jù)
 List<User> list=userService.selectAll();
//封裝分頁參數(shù)返回給前臺(tái)
PageInfo pageInfo = new PageInfo(list);
return pageInfo;
}

如果失效,可以在pom里面添加aop依賴在試

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-aop</artifactId>
</dependency>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論