当前位置:   article > 正文

分页插件报类型转换异常: class java.util.ArrayList cannot be cast to class com.github.pagehelper.Page(最新解决方法)

class java.util.arraylist cannot be cast to class com.github.pagehelper.page

问题描述

在springboot和mybatis中使用分页插件时报错:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.github.pagehelper.Page (java.util.ArrayList is in module java.base of loader 'bootstrap'; com.github.pagehelper.Page is in unnamed module of loader 'app') 试了很多方法都没有解决


原因分析:

实际上只是引入的pagehelper版本低了,和项目中使用的其他库的版本不兼容。版本不匹配导致了类型转换错误。

解决方案:

pom.xml文件中将引入的pagehelper依赖的版本更新为1.4.7即可,以下是分页插件的依赖,直接将其复制粘贴到pom.xml文件中,刷新。若刷新失败就重启一下idea,再次打开后会自动下载更新版本(注:我用的Java版本为17,JDK20,springboot版本是3.x.x)

  1. <!-- 分页插件 -->
  2. <dependency>
  3. <groupId>com.github.pagehelper</groupId>
  4. <artifactId>pagehelper-spring-boot-starter</artifactId>
  5. <version>1.4.7</version>
  6. </dependency>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/808653
推荐阅读
相关标签
  

闽ICP备14008679号