解决Maven项目中 Invalid bound statement 无效的绑定问题

网友投稿 907 2022-10-20


解决Maven项目中 Invalid bound statement 无效的绑定问题

问题

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

关于这个问题,我的是 Maven 项目,在访问程序的接口时,抛出异常信息,无效的绑定语句。

在检查调用的 Mapper 接口时,发现在目标文件中没有找到 Mapper 映射的配置文件,在项目的 target 目标文件中可以看到,与接口对应的 Mapper 文件未加载,所以在程序启动时,就找不到对应的映射文件,导致的这个错误。

解决方法

在 pom 配置文件中键入 节点,并指明资源类型,这样在程序启动时,就可以正确加载配置文件了:

java中的配置资源类型:

src/main/java

&QKjlGzlt;includes>

**/*.properties

**/*.xml

false

Resource中的配置资源类型:

src/main/resources

**/*.properties

**/*.xml

false

当然项目需求可以同时键入两个:

src/main/java

**/*.properties

**/*.xml

false

src/main/resources

**/*.properties

*QKjlGz*/*.xml

false

键入 节点后,在次启动项目,在项目的 target 目标文件中,就可以看到接口对应的映射文件了,问题解决咯!!!!

开发maven时遇到无效的绑定语句(未找到),org.apache.ibatis.binding.BindingException:

今天做一个springmvc+mybatis的maven项目时运行登录时报错,显示找不到绑定语句

日志文件如下

严重 [http-nio-8080-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [crm] in context with path [/boot_crm_war] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.itheima.core.dao.UserDao.findUser] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.itheima.core.dao.UserDao.findUser

at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:230)

at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:48)

at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)

at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)

at com.sun.proxy.$Proxy15.findUser(Unknown Source)

at com.itheima.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:20)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)

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)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)

at com.sun.proxy.$Proxy19.findUser(Unknown Source)

at com.itheima.core.web.controller.UserController.login(UserController.java:25)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)

at org.springframework.web.methoQKjlGzd.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:748)

我按照网上的方法怎么看都没发现自己有错误,很烦恼。但是他说找不到绑定语句,我明明绑定语句没有错误,为什么找不到呢?于是我去target文件夹看看我的classes有没有编译出来,看了之后一目了然。

我们的class文件被编译了,但是绑定语句xml文件没有被编译。

在做maven项目时,以后都要注意一个点,要在build标签里加上这个语句

src/main/java

**/*.xml

true

xml文件才能够被编译。加入之后重新编译,文件夹就多了xml文件。

问题解决。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:数据中心合并点布线
下一篇:案例分析:探究硅谷数据中心节能项目
相关文章

 发表评论

暂时没有评论,来抢沙发吧~