spring boot配置pagehelper插件
一、maven配置
<mybatis-spring.version>2.1.1</mybatis-spring.version>
<pagehelper-spring.version>1.2.3</pagehelper-spring.version>
<pagehelper.version>5.1.8</pagehelper.version>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-spring.version}</version>
<exclusions>
<exclusion>
<artifactId>pagehelper</artifactId>
<groupId>com.github.pagehelper</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
二、配置文件配置
application.yml
pagehelper:
helperDialect: mysql
#开启优化,如果开启优化,在分页页码结果没有数据的时候,会显示有数据的页码数据
reasonable: true
#是否支持接口参数来传递分页参数,默认false
supportMethodsArguments: true
#pageSize=0 返回所有
pageSizeZero: false
params: count=countSql
三、使用
PageHelper.startPage(pageNo,pageSize);
userService.getUsers();