pagehelper / Mybatis-PageHelper

Mybatis通用分页插件
https://mybatis.io
MIT License
12.18k stars 3.13k forks source link

pagehelper-spring-boot-starter1.4.3分页失败导致全量查询 #745

Open LeiYuBoGitHub opened 1 year ago

LeiYuBoGitHub commented 1 year ago

依赖模块

spring-boot-starter-web [3.0.6]
mysql-connector-java [5.1.46]
druid [1.2.17]
mybatis-plus-boot-starter [3.5.3.1]
pagehelper-spring-boot-starter [1.4.3]

分页代码

 try (Page<Object> page = PageHelper.startPage(request.getPage(), 10)) {
            StudentParam param = new StudentParam();
            param.setId(request.getStudentId());
            param.setPhone(request.getPhone());
            param.setCardNo(request.getCardNo());
            param.setAccount(request.getAccount());
            beanList = studentRepository.getList(param);
            total = Long.valueOf(page.getTotal()).intValue();
        }

问题 分页失败 导致全量查询 数据库IO请求飙升

解决方案

升级 pagehelper-spring-boot-starter 从1.4.3 到1.4.6 即可解决

需求

能否简单解释下为什么导致此问题 还是因为1.4.3不支持spring boot 过高版本

abel533 commented 1 year ago

可以看看更新日志中有没有对这里有影响的。

quccwang commented 1 year ago

遇到和你一样的问题,就是版本依赖不兼容导致的,这得看源码了,springboot高版本必须匹配高版本的第三方jar包,或者降低springboot的版本