java.util.ArrayList cannot be cast to com.baomidou.mybatisplus.core.metadata.IPage
时间: 2023-10-08 21:06:25 浏览: 55
这个错误通常是因为在使用 MybatisPlus 的分页查询时,返回结果类型没有指定为 IPage 类型。
你可以检查一下你的代码中,是否有以下类似的代码:
```
List<Student> students = studentMapper.selectPage(page, wrapper);
```
这里的返回类型是 List,而不是 IPage,导致类型转换异常。
要解决这个问题,你需要将返回类型改为 IPage,例如:
```
IPage<Student> studentPage = studentMapper.selectPage(page, wrapper);
List<Student> students = studentPage.getRecords();
```
或者你可以在 MybatisPlus 的配置文件中配置全局的返回类型,例如:
```
mybatis-plus:
configuration:
default-fetch-size: 100
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
default-statement-timeout: 3000
default-result-type: com.baomidou.mybatisplus.core.metadata.IPage
```
这样,在你的代码中就不需要指定返回类型了,MybatisPlus 会自动将结果转换为 IPage 类型。