pom.xml
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.2</version>
</dependency>
排除pagehelper的依赖mybatis和mybatis-spring的jar包以免与mybatis-plus的冲突,导致报NoClassFound org.mybatis.logging.LoggerFactory
application.yml
pagehelper:
reasonable: false # 禁用合理化时,如果pageNum<1或pageNum>pages会返回空数据
support-methods-arguments: true
params: count=countSql
row-bounds-with-count: true
helper-dialect: mysql
案例代码
@Test
public void testSelectPageHelper(){
PageHelper.startPage(0, 5);
List<User> users = userMapper.selectList(null);
PageInfo<User> pageInfo = new PageInfo(users, 5);
System.out.println(pageInfo);
}