mybatis use pagehelper plug

1. Add rely on plug-ins

<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. Add a profile

pagehelper.helper-dialect=mysql
pagehelper.params=count=countSql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true

3. New Test class Test

@GetMapping ( " / List " ) 
@ResponseBody 
public PageInfo <the User> getUserList () {
 // tab pages and also the number of the starting 
 PageHelper.startPage ( 0 , . 5 );
 // call query method, when the query method return data has been paged 
 List <the User> List = userService.selectAll ();
 // package paging parameters returned to the front 
PageInfo PageInfo = new new PageInfo (List);
 return PageInfo; 
}


If the failure can be added in the trial in dependence aop inside pom

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

 

 

Guess you like

Origin www.cnblogs.com/red-star/p/12057112.html