使用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>

 

posted @ 2021-04-28 14:22  万里哥  阅读(4023)  评论(0编辑  收藏  举报