nested exception is org.apache.ibatis.binding.BindingException: Invalid (not found)

来源:互联网 发布:洞主手工皂淘宝在哪 编辑:程序博客网 时间:2024/06/16 23:16

这个错误情况有很多,就说最坑的一种:找不到mapper文件

错误信息

type Exception reportmessage Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ke.service.ItemService.getStudentByIddescription The server encountered an internal error that prevented it from fulfilling this request.exceptionorg.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ke.service.ItemService.getStudentByIdorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)javax.servlet.http.HttpServlet.service(HttpServlet.java:622)org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)javax.servlet.http.HttpServlet.service(HttpServlet.java:729)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)root causeorg.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ke.service.ItemService.getStudentByIdorg.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225)org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)com.sun.proxy.$Proxy18.getStudentById(Unknown Source)com.ke.controller.HomeController.getItemById(HomeController.java:22)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)javax.servlet.http.HttpServlet.service(HttpServlet.java:622)org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)javax.servlet.http.HttpServlet.service(HttpServlet.java:729)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)note The full stack trace of the root cause is available in the Apache Tomcat/9.0.0.M1 logs.

因为maven工程在打包文件时不会将java目录里面的XML打包过去,所以在target里面是找不到mapper文件的,因此我们需要在pom.xml加上一段

<build>        <resources>            <resource>                <directory>src/main/java</directory>                <includes>                    <include>**/*.properties</include>                    <include>**/*.xml</include>                </includes>                <filtering>false</filtering>            </resource>        </resources>    </build>


阅读全文
0 0