kangyongh的gravatar头像
kangyongh 2018-07-02 11:02:32

ssm中加上PageHelper.startPage(pagenum,pagesize)后为什么抛出如下错误?

2018-07-02 10:50:45,722 DEBUG [org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver] - Resolving exception from handler [org.com.system.kyh.controller.MessageController@1a7c215]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
### Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
2018-07-02 10:50:45,723 DEBUG [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] - Resolving exception from handler [org.com.system.kyh.controller.MessageController@1a7c215]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
### Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
2018-07-02 10:50:46,067 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Could not complete request
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
### Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346)
 at $Proxy23.selectList(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:182)
 at org.com.system.kyh.daoImpl.MessageDaoImpl.list(MessageDaoImpl.java:18)
 at org.com.system.kyh.serviceImpl.MessageServiceImpl.list(MessageServiceImpl.java:74)
 at org.com.system.kyh.controller.MessageController.query(MessageController.java:62)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
 at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
 at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
 at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
### Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
 at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:80)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:68)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
 ... 40 more
Caused by: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
 at com.github.pagehelper.SqlUtil.processMappedStatement(SqlUtil.java:312)
 at com.github.pagehelper.SqlUtil.doProcessPage(SqlUtil.java:460)
 at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:407)
 at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:374)
 at com.github.pagehelper.PageHelper.intercept(PageHelper.java:255)
 at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:42)
 at $Proxy32.query(Unknown Source)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)
 ... 47 more
2018-07-02 10:50:46,072 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor'
2018-07-02 10:50:46,072 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'org.springframework.scheduling.config.ContextLifecycleScheduledTaskRegistrar#0'
2018-7-2 10:50:46 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [springmvc] in context with path [/system] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
### Cause: java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource] with root cause
java.lang.RuntimeException: 无法处理该类型[class org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource]的SqlSource
 at com.github.pagehelper.SqlUtil.processMappedStatement(SqlUtil.java:312)
 at com.github.pagehelper.SqlUtil.doProcessPage(SqlUtil.java:460)
 at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:407)
 at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:374)
 at com.github.pagehelper.PageHelper.intercept(PageHelper.java:255)
 at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:42)
 at $Proxy32.query(Unknown Source)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:68)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
 at $Proxy23.selectList(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:182)
 at org.com.system.kyh.daoImpl.MessageDaoImpl.list(MessageDaoImpl.java:18)
 at org.com.system.kyh.serviceImpl.MessageServiceImpl.list(MessageServiceImpl.java:74)
 at org.com.system.kyh.controller.MessageController.query(MessageController.java:62)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
 at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
 at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
 at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:662)

所有回答列表(1)
kangyongh的gravatar头像
kangyongh  LV10 2018年7月2日

问题已经解决,这个问题之所以出现,是因为在使用mybatis的时候版本比较低,导致PageHelper使用分页的时候无法使用,建议最好用

 <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.4.2</version>
        </dependency>
         <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis-spring</artifactId>  
            <version> 1.3.1</version>  
        </dependency>

及以上版本

评论(0) 最佳答案
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友