mybatisplus和pagehelper导致total为0
记一次mybatisplus分页踩坑,程序不报错,能正常运行,分页的page对象中total和pages总是0.
mybatisplus2.2.0和pagehelper1.2.12同时存在
会导致mybatisplus的分页失效,会出现 “total”: 0,“pages”: 0 的情况
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
去掉pagehelper之后分页正常
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!--<dependency>-->
<!-- <groupId>com.github.pagehelper</groupId>-->
<!-- <artifactId>pagehelper-spring-boot-starter</artifactId>-->
<!-- <version>1.2.12</version>-->
<!--</dependency>-->
解决办法一:去掉pagehelper
解决办法二:升级mybatisplus版本
亲测mybatisplus3.3.0和pagehelper1.2.12可行
其他版本不一定行,可以自己试验下
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.0</version>
</dependency>