求助:java.util.ArrayList cannot be cast to com.github.pagehelper.Page

Excalibur_辉 2017-07-20 10:44:47
在同一个工程下
最开始用com.github.pagehelper插件进行数据分页没有配置spring导致类型转换不了,加上配置就OK了
现在开发另一个接口spring也配置了但是又出了这个问题,求大神帮助

maven:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>3.7.0</version>
</dependency>

spring:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.seebon.entity" />
<property name="mapperLocations" value="classpath*:mybatis/**/*.xml" />
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<value>
dialect=mysql
reasonable=true
rowBoundsWithCount=true
offsetAsPageNum=true
pageSizeZero=true
</value>
</property>
</bean>
</array>
</property>
</bean>

程序报错代码:
List<CustomerDebtCollection> collection = new ArrayList<>();
PageHelper.startPage(1 , 1);
Page<CustomerDebtCollection> page = (Page<CustomerDebtCollection>)collection;

强转的时候就报类型不对
(collection size=2,因为中间业务代码太多就没有贴出来了)
...全文
3938 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Buguanjia-Ssj 2017-07-20
  • 打赏
  • 举报
回复
借鉴2l大神的话,两个完全没关系的类怎么能强转呢,自己写个private方法老老实实转吧,别搞骚操作
李德胜1995 2017-07-20
  • 打赏
  • 举报
回复
Page<CustomerDebtCollection> page = (Page<CustomerDebtCollection>)collection; java.util.ArrayList cannot be cast to com.github.pagehelper.Page,List和Page没关系,不能向下转型。。。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧