当前使用版本(必须填写清楚,否则不予处理)

3.2.0

该问题是怎么引起的?(最新版上已修复的会直接close掉)

使用分页插件,没执行到MybatisPlusConfig类中(通过打断点确认)

重现步骤

  1. MybatisPlusConfig 文件:
package com.zw.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
@Configuration
@MapperScan("com.zw.phtracker.mapper")
@ConditionalOnClass(value= {PaginationInterceptor.class})
public class MybatisPlusConfig {

    @Bean
    public PaginationInterceptor  paginationInterceptor() {
           PaginationInterceptor page = new PaginationInterceptor();
            page.setDialectType("mysql");
            return page;
    }
}
  1. controller文件:
//封装查询条件:
    QueryWrapper<Product> queryWrapper=new QueryWrapper<>();    
    //当页面上几个查询条件不为空时,才执行
    queryWrapper.ge(productVo.getStartDate()!=null,"launch_time", productVo.getStartDate());
    queryWrapper.le(productVo.getEndDate()!=null,"launch_time",productVo.getEndDate());
    queryWrapper.ge(productVo.getStartVotes()!=null,"votes", productVo.getStartVotes());
    queryWrapper.le(productVo.getEndVotes()!=null,"votes",productVo.getEndVotes()); 
    queryWrapper.orderByDesc("votes");

    IPage<Product> page=new Page<>(productVo.getPage(), productVo.getLimit());      
    productService.page(page, queryWrapper);
    return new DataGridView(page.getTotal(), page.getRecords());

3.Mapper配置:

#配置mybatisplus
mybatis-plus:
  mapper-locations:
    classpath:mapper/*Mapper.xml

4.代码目录: MyBatis-Plus 使用分页插件,没执行到MybatisPlusConfig类中(通过打断点确认)

报错信息

page.getRecords()返回正常,page.getTotal()返回0. 执行的sql中没有limit参数:

SELECT id,img_url,product_desc,launch_time,maker,votes,maker_url,product_url,product_name FROM product WHERE (votes >= ? AND votes <= ?) ORDER BY votes DESC

Comment From: miemieYaho

自己排查

Comment From: hpan

遇到了同样的问题,好奇怪