SpringBoot + PageHelper, MyBatis pagination does not take effect Solution

PageHelper is a good pagination plug Mybatis, but to use it pagination to note the following points.

1. Import related packets, such as introducing dependent maven

1 <dependency>
2     <groupId>com.github.pagehelper</groupId>
3     <artifactId>pagehelper</artifactId>
4     <version>5.1.4</version>
5 </dependency>

Note that SpringBoot use the pagehelper-spring-boot-starter.

1 <dependency>
2     <groupId>com.github.pagehelper</groupId>
3     <artifactId>pagehelper-spring-boot-starter</artifactId>
4     <version>1.2.3</version>
5 </dependency>

 

2. Add the plug-in mybatis-config.xml

1 <plugins>
2    <plugin interceptor="com.github.pagehelper.PageInterceptor">
3         <!--分页参数合理化  -->
4         <property name="reasonable" value="true"/>
5    </plugin>
6 </plugins>

SpringBoot yml profile configuration mode

1  pagehelper:
 2    helperDialect: MySQL
 3    Reasonable: to true   # turn on optimization, if open optimization, when there is no data in the page numbers result will show the data of the page data
 4    supportMethodsArguments: to true # whether to support the interface parameters to pass paging parameters, default to false
 . 5    pageSizeZero: to false # = 0 the pageSize returns all
 . 6    the params: COUNT = countSql

 

PageHelper official website: https://pagehelper.github.io/docs

Guess you like

Origin www.cnblogs.com/yapin/p/11925579.html