使用Mybatis-Plus进行分页查询,返回的数据中total总是为0的问题?可以参考以下两种解决方案


背景:今天想简单研究一下mybatis-plus分页,没想到给我整懵逼了,total总数一直给我返回0,能返回数据,但分页失效,气死,搞半天发现还需要注入一个Bean对象 PaginationInterceptor即可。

 

一、创建一个类注入PaginationInterceptor

 

@Configuration
public class MybatisPlusConfig {

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}

 

二、去除pom.xml中的pagehelper的jar包

 

<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.3</version>
  </dependency>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM