老师工具类没法加载

来源:4-1 PageHelper分页插件

qq_慕莱坞4316410

2020-01-10 11:54:44

"D:\Program Files\Java\jdk-9.0.4\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\IDEA开发工具\资料\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=55327:D:\IDEA开发工具\资料\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "D:\IDEA开发工具\资料\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar;D:\IDEA开发工具\资料\IntelliJ IDEA 2019.1.3\plugins\junit\lib\junit-rt.jar;D:\IDEA开发工具\资料\IntelliJ IDEA 2019.1.3\plugins\junit\lib\junit5-rt.jar;D:\基础知识复习\Mybatis基础知识学习\target\test-classes;D:\基础知识复习\Mybatis基础知识学习\target\classes;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\org\mybatis\mybatis\3.5.1\mybatis-3.5.1.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\mysql\mysql-connector-java\8.0.11\mysql-connector-java-8.0.11.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\com\google\protobuf\protobuf-java\2.6.0\protobuf-java-2.6.0.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\com\github\pagehelper\pagehelper\5.1.10\pagehelper-5.1.10.jar;C:\Users\Administrator.DESKTOP-44IIV5B\.m2\repository\com\github\jsqlparser\jsqlparser\2.0\jsqlparser-2.0.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 TestMybatis,DemoTest08


java.lang.ExceptionInInitializerError

at TestMybatis.DemoTest08(TestMybatis.java:142)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:564)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: org.apache.ibatis.exceptions.PersistenceException: 

### Error building SqlSession.

### The error may exist in SQL Mapper Configuration

### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.gitthub.pagehelper.pageInterceptor'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.gitthub.pagehelper.pageInterceptor

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)

at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:52)

at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:36)

at com.imooc.util.MyBatisUtil.<clinit>(MyBatisUtil.java:21)

... 23 more

Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.gitthub.pagehelper.pageInterceptor'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.gitthub.pagehelper.pageInterceptor

at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:121)

at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:98)

at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:50)

... 25 more

Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.gitthub.pagehelper.pageInterceptor'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.gitthub.pagehelper.pageInterceptor

at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)

at org.apache.ibatis.builder.xml.XMLConfigBuilder.pluginElement(XMLConfigBuilder.java:188)

at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:110)

... 27 more

Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.gitthub.pagehelper.pageInterceptor'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.gitthub.pagehelper.pageInterceptor

at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)

at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)

at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)

... 29 more

Caused by: java.lang.ClassNotFoundException: Cannot find class: com.gitthub.pagehelper.pageInterceptor

at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200)

at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)

at org.apache.ibatis.io.Resources.classForName(Resources.java:261)

at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)

... 31 more



Process finished with exit code -1

@Test
public void DemoTest09() throws Exception {
      SqlSession sqlsession=null;
      try{
             sqlsession=MyBatisUtil.opeanSeeion();
             PageHelper.startPage(2,10);
             Page<Goods>page=(Page)sqlsession.selectList("MybatisOperation.selectPage");
             System.out.println("数据总共页数:"+page.getPages());
             System.out.println("数据总记录数:"+page.getTotal());
             System.out.println("开始页数:"+page.getStartRow());
             System.out.println("结束页数:"+page.getEndRow());
             System.out.println("当前页数:"+page.getPageNum());
             List<Goods>Page=page.getResult();
             for (Goods good : Page){
                    System.out.println(good.getSubTitle()+good.getCurrentPrice());
             }
      }catch (Exception e){
             throw e;
      }finally {
             MyBatisUtil.colseSession(sqlsession);
      }
}

老师为什么工具类没法加载啊

写回答

1回答

qq_慕莱坞4316410

提问者

2020-01-10

老师找到问题答案了,但是我的这个

java.lang.ClassCastException: java.base/java.util.ArrayList cannot be cast to com.github.pagehelper.Page


at TestMybatis.DemoTest09(TestMybatis.java:159)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:564)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

强转失败了

@Test
public void DemoTest09() throws Exception {
      SqlSession sqlsession=null;
      try{
             sqlsession= MyBatisUtil.opeanSeeion();
             PageHelper.startPage(2,10);
             Page<Goods>page=(Page) sqlsession.selectList("MybatisOperation.selectPage");
             System.out.println("数据总共页数:"+page.getPages());
             System.out.println("数据总记录数:"+page.getTotal());
             System.out.println("开始页数:"+page.getStartRow());
             System.out.println("结束页数:"+page.getEndRow());
             System.out.println("当前页数:"+page.getPageNum());
             List<Goods>Page=page.getResult();
             for (Goods good : Page){
                    System.out.println(good.getSubTitle()+good.getCurrentPrice());
             }
      }catch (Exception e){
             throw e;
      }finally {
             MyBatisUtil.colseSession(sqlsession);
      }
}

怎么失败啊

0
hq_慕莱坞4316410
h 在自己莫名其妙的操作下处理好了,谢谢老师了
h020-01-10
共2条回复

0 学习 · 8016 问题

查看课程