当前使用版本(必填,否则不予处理)
mybatis-plus-boot-starter 3.5.1
该问题是如何引起的?(确定最新版也有问题再提!!!)
最新的分页插件PaginationInnerInterceptor 分页失败 会查询所有数据。 records返回所有数据。
重现步骤(如果有就写完整)
controller
@RestController
@RequestMapping("tblEmployee")
public class TblEmployeeController {
/**
* 服务对象
*/
@Autowired
private TblEmployeeService tblEmployeeService;
@GetMapping("/queryByPage")
public IPage queryByPage() {
IPage<TblEmployee> page = tblEmployeeService.page(new Page<>(2,2),new QueryWrapper<TblEmployee>());
return page;
}
}
config
@Configuration
@EnableTransactionManagement //开启事务
public class MyBatisConfig {
//引入分页插件
@Bean
public PaginationInnerInterceptor paginationInterceptor() {
PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
paginationInterceptor.setOverflow(true);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor.setMaxLimit(500L);
return paginationInterceptor;
}
}
返回信息
{
"records": [
{
"id": 1,
"lastName": "Tom",
"email": "tom@atguigu.com",
"gender": "1",
"age": 22,
"myName": null
},
{
"id": 2,
"lastName": "Jerry",
"email": "jerry@atguigu.com",
"gender": "0",
"age": 25,
"myName": null
},
{
"id": 3,
"lastName": "Black",
"email": "black@atguigu.com",
"gender": "1",
"age": 30,
"myName": null
},
{
"id": 4,
"lastName": "White",
"email": "white@atguigu.com",
"gender": "0",
"age": 35,
"myName": null
},
{
"id": 5,
"lastName": "234",
"email": "123",
"gender": "1",
"age": 1,
"myName": null
}
],
"total": 0,
"size": 2,
"current": 2,
"orders": [
],
"optimizeCountSql": true,
"searchCount": true,
"countId": null,
"maxLimit": null,
"pages": 0
}
报错信息
records返回全部5条数据,size显示两条
Comment From: langwuzhe
分页已经改版了没看见:https://baomidou.com/pages/8f40ae/
Comment From: diego1109
遇到同样的问题,链接404了
Comment From: diego1109
分页已经改版了没看见:https://baomidou.com/pages/8f40ae/
找到问题了 @MybatisPlusTest 在单测中没有使分页生效。
Comment From: aqucy
遇到了同样的问题,使用原先的PaginationInterceptor就好使