mybatis-plus集成pagehelper

pom.xml


    com.github.pagehelper
    pagehelper-spring-boot-starter
    1.2.3
    
        
            org.mybatis
            mybatis
        
        
            org.mybatis
            mybatis-spring
        
    


    com.baomidou
    mybatis-plus-boot-starter
    3.1.2

排除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);
}

你可能感兴趣的:(myabtis-plus)