Fix a problem that always prompts you not to find a way to mapper the definition of a file!

Source: Internet
Author: User

The mybatis of the *mapper.xml file is a terrible disaster! For two whole days circling around this problem!

Let's see what the problem looks like! Here is the Mapper.xml file generated by reverse engineering, the package path is nothing wrong!

But every time you invoke the operations database of a method in mapper, it fails:

Put out detailed error message:

1March +, . Ten: -: $Afternoon Org.apache.catalina.core.ApplicationContext Log2 Info: No Spring webapplicationinitializer types detected on Classpath3March +, . Ten: -: $Afternoon Org.apache.catalina.core.ApplicationContext Log4 Info: Initializing Spring root Webapplicationcontext5March +, . Ten: -: -Afternoon Org.apache.catalina.core.ApplicationContext Log6Info: Initializing Spring frameworkservlet'Xuebusi-manager'7March +, . Ten: -: +pm Org.apache.catalina.core.StandardWrapperValve Invoke 8 severity: Servlet.service () for Servlets [Xuebusi-manager] in the 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.selectByExample10 at Org.apache.ibatis.binding.mappermethod$sqlcommand .<init> (mappermethod.java:189) at org.apache.ibatis.binding.mappermethod.<init> (MapperMethod.java : To Org.apache.ibatis.binding.MapperProxy.cachedMapperMethod (mapperproxy.java:58) at Org.apache.ibatis.bin Ding. Mapperproxy.invoke (mapperproxy.java:51) in Com.sun.proxy. $Proxy 19.selectByExample (Unknown Source) at Com.xuebu Si.service.impl.UserServiceImpl.getUserById (userserviceimpl.java:66) at SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) at Sun.reflect. Nativemethodaccessorimpl.invoke (nativemethodaccessorimpl.java:57) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (method.java:606) at Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317) at Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (Reflectivemethodinvocation.java : Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed at (Reflectivemethodinvocation.java : 157) at Org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation ( TRANSACTIONINTERCEPTOR.JAVA:99) at Org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction ( transactionaspectsupport.java:267) at Org.springframework.transaction.interceptor.TransactionInterceptor.invoke (transactioninterceptor.java:96) at Org.springframework.aop.framework.ReflectiveMethoDinvocation.proceed (reflectivemethodinvocation.java:179) 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)-at com.sun.proxy.$ Proxy20.getuserbyid (Unknown Source) at Com.xuebusi.controller.TestController.getUserById (testcontroller.java:50 ) at the SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invok E (nativemethodaccessorimpl.java:57) at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (method.java:606), at Org.springframewo Rk.web.method.support.InvocableHandlerMethod.doInvoke (invocablehandlermethod.java:221) Notoginseng at Org.springframework.web.method.support.Invocablehandlermethod.invokeforrequest (invocablehandlermethod.java:137) at Org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle ( SERVLETINVOCABLEHANDLERMETHOD.JAVA:110) at Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod ( requestmappinghandleradapter.java:777) Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal ( requestmappinghandleradapter.java:706) at Org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle ( abstracthandlermethodadapter.java:85) at Org.springframework.web.servlet.DispatcherServlet.doDispatch ( dispatcherservlet.java:943) at Org.springframework.web.servlet.DispatcherServlet.doService ( dispatcherservlet.java:877) at Org.springframework.web.servlet.FrameworkServlet.processRequest ( frameworkservlet.java:966) at Org.springframework.web.servlet.FrameworkServlet.doGET (frameworkservlet.java:857) in Javax.servlet.http.HttpServlet.service (httpservlet.java:624) at Org.springfra Mework.web.servlet.FrameworkServlet.service (frameworkservlet.java:842) at Javax.servlet.http.HttpServlet.service (httpservlet.java:731) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:303) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:208) Wuyi at Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:241) 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) 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:505) at Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:169) at Org.apache.catalina.valves.ErrorReportValve.invoke (errorreportvalve.java:103) Org.apache.catalina.valves.AccessLogValve.invoke (accesslogvalve.java:956) at Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:116) Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:436) at Org.apache.coyote.http11.AbstractHttp11Processor.process (abstracthttp11processor.java:1078) at Org.apache.coyote.abstractprotocol$abstractconnectionhandler.process (abstractprotocol.java:625) at Org.apache.tomcat.util.net.jioendpoint$socketprocessor.run (jioendpoint.java:318) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run (taskthread.java:61) at Java.lang.Thread.run ( thread.java:745)

Tossing for two days, occasionally on the Internet to see the following solutions, only to be solved (want to cry a):

To determine if your Mapper.xml file really does not have a problem, try to modify the project's Pom.xml file, add the following content:

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>Ten     </Build>

Fix a problem that always prompts you not to find a way to mapper the definition of a file!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.