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

Author: LeiYuBoGitHubCreated May 26, 2023Updated Jul 8, 2025
  • 我已在 issues 搜索类似问题,并且不存在相同的问题.

依赖模块

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 过高版本

Source: pagehelper-org/Mybatis-PageHelper