码迷,mamicode.com
首页 > 移动开发 > 详细

解决老是提示找不到Mapper文件无法执行定义的方法问题!

时间:2017-03-19 23:34:10      阅读:3295      评论:0      收藏:0      [点我收藏+]

标签:filter   runnable   XML   manager   org   frame   get   proxy   stc   

 尼玛,被mybatis的*Mapper.xml文件害惨了!整整两天都在围绕这个问题转圈!

 

先看问题长啥样吧!下面是通过逆向工程生成的Mapper.xml文件,包路径什么的都没有错!

技术分享

但是每次调用Mapper中的方法的操作数据库的时候都失败:

技术分享

 

 贴出来详细的报错信息:

 1 三月 19, 2017 10:16:45 下午 org.apache.catalina.core.ApplicationContext log
 2 信息: No Spring WebApplicationInitializer types detected on classpath
 3 三月 19, 2017 10:16:45 下午 org.apache.catalina.core.ApplicationContext log
 4 信息: Initializing Spring root WebApplicationContext
 5 三月 19, 2017 10:16:48 下午 org.apache.catalina.core.ApplicationContext log
 6 信息: Initializing Spring FrameworkServlet xuebusi-manager
 7 三月 19, 2017 10:20:40 下午 org.apache.catalina.core.StandardWrapperValve invoke
 8 严重: Servlet.service() for servlet [xuebusi-manager] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xuebusi.mapper.TbUserMapper.selectByExample] with root cause
 9 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xuebusi.mapper.TbUserMapper.selectByExample
10     at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
11     at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
12     at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
13     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
14     at com.sun.proxy.$Proxy19.selectByExample(Unknown Source)
15     at com.xuebusi.service.impl.UserServiceImpl.getUserById(UserServiceImpl.java:66)
16     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
18     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19     at java.lang.reflect.Method.invoke(Method.java:606)
20     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
21     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
22     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
23     at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
24     at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:267)
25     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
26     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
27     at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
28     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
29     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
30     at com.sun.proxy.$Proxy20.getUserById(Unknown Source)
31     at com.xuebusi.controller.TestController.getUserById(TestController.java:50)
32     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
33     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
34     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
35     at java.lang.reflect.Method.invoke(Method.java:606)
36     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
37     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
38     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
39     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
40     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
41     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
42     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
43     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
44     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
45     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
46     at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
47     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
48     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
49     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
50     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
51     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
52     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
53     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
54     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
55     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
56     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
57     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
58     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
59     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
60     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
61     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
62     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
63     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
64     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
65     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
66     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
67     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
68     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
69     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
70     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
71     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
72     at java.lang.Thread.run(Thread.java:745)

 

技术分享

 

 折腾了两天,偶尔在网上见网友如下解决方案,才算是解决了(想大哭一场):

技术分享

确定你的mapper.xml文件确实是没有的问题的,就尝试修改项目的pom.xml文件,添加如下内容即可:

 1     <build>
 2         <resources>
 3             <resource>
 4                 <directory>src/main/java</directory>
 5                 <includes>
 6                     <include>**/mapper/*Mapper.xml</include>
 7                 </includes>
 8             </resource>
 9         </resources>
10     </build>

 

解决老是提示找不到Mapper文件无法执行定义的方法问题!

标签:filter   runnable   XML   manager   org   frame   get   proxy   stc   

原文地址:http://www.cnblogs.com/jun1019/p/6582824.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!