ArrayList cannot be cast to com.github.pagehelper.Page
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArrayList cannot be cast to com.github.pagehelper.Page相关的知识,希望对你有一定的参考价值。
参考技术A PageHelper.startPage(page,pageSize);只对紧跟着的查询结果进行分页!cannot be cast to
java.lang.ClassCastException: com.service.impl.OrderPlanServiceImpl cannot be cast to com.provider.service.IUserInfoService
at com.easylabplus.provider.test.UserInfoTest.testUserInfoService(UserInfoTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
问题提示没有在第二个类当中找到你注册的Service名字
原因是我的测试类中没有写好Service对应的映射名字
1 @Test 2 public void testUserInfoService() throws Exception { 3 ClassPathXmlApplicationContext aContext = new ClassPathXmlApplicationContext( 4 "applicationContext.xml"); 5 //问题就是下边这个userInfoService的名字写错了 6 IUserInfoService userInfoService = (IUserInfoService) aContext 7 .getBean("userInfoService"); 8 List<UserInfo> list = userInfoService.queryAll(); 9 Gson g = new Gson(); 10 System.out.println(g.toJson(list)); 11 12 }
以上是关于ArrayList cannot be cast to com.github.pagehelper.Page的主要内容,如果未能解决你的问题,请参考以下文章
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Map
PageHelper分页异常(java.base/java.util.ArrayList cannot be cast to com.github.pagehelper.Page)
cannot be cast to javax.servletFilter