使用junit测试分页是否成功时出现错误:
java.lang.NoSuchMethodError:org.apache.ibatis.reflection.MetaObject.forObject(Ljava/lang/Object;Lorg/apache/ibatis/reflection/factory/ObjectFactory;Lorg/apache/ibatis/reflection/wrapper/ObjectWrapperFactory;)Lorg/apache/ibatis/reflection/MetaObject;
atcom.github.pagehelper.SqlUtil.forObject(SqlUtil.java:78)
atcom.github.pagehelper.SqlUtil.getsqlSource(SqlUtil.java:521)
atcom.github.pagehelper.SqlUtil.getMappedStatement(SqlUtil.java:444)
atcom.github.pagehelper.SqlUtil.processCountMappedStatement(SqlUtil.java:143)
atcom.github.pagehelper.PageHelper.intercept(PageHelper.java:140)
atorg.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
atcom.sun.proxy.$Proxy17.query(Unknown Source)
atorg.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
atorg.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
atjava.lang.reflect.Method.invoke(Unknown Source)
atorg.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
atcom.sun.proxy.$Proxy10.selectList(Unknown Source)
atorg.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
atorg.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
atorg.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
atorg.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
atcom.sun.proxy.$Proxy11.selectByExample(Unknown Source)
atcom.taotao.controller.TestPageHelper.testPageHelper(TestPageHelper.java:56)
atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
atjava.lang.reflect.Method.invoke(Unknown Source)
atorg.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
atorg.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
atorg.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
atorg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
atorg.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
atorg.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
atorg.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
atorg.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
atorg.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
atorg.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
atorg.junit.runners.ParentRunner.run(ParentRunner.java:292)
atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
网上搜索了好久才知道原来是MetaObject.forObject()方法传的参数不对,原来是我的mybatis版本太高,默认的参数与原来的不同,然后在taotao-parent的pom.xml把mybatis的版本改成和老师的3.2.8一样即可