pageHelper:好处就是使用简单,自动帮忙进行物理分割查询
-
断点截图
表中有4条数据,mapper是查询所有数据的。根据断点截图,可以看出pageHelper的确是进行了物理分割查询
//查询所有产品信息
@Select({"select * from", TABLE_NAME})
List<Product> SelectProducts();
![](https://img.haomeiwen.com/i8192147/d01bcb99e42a5ff8.png)
-
网上教程的坑
SpringBoot只需要这个依赖就行了,其它都自带或内包括了。网上很多教程会把pagehelper、pagehelper-spring-boot-autoconfigure都放进依赖,虽然不会报错,但是不优雅!!!
<!-- SpringBoot不需要以下二个插件依赖 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.3</version>
</dependency>
<!-- 只需要下面这个插件依赖就行了 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
-
YML配置也简单
#配置分页插件pagehelper
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
网友评论