Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)
Posted mp-ui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)相关的知识,希望对你有一定的参考价值。
今天做Web作业的时候用到了Spring、SpringMVC、Mybatis整合的时候,发现Mybatis访问数据的时候报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.prince.dao.ArticleMapper.selectByExampleWithBLOBs
org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53)
org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:115)
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:102)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
com.sun.proxy.$Proxy19.selectByExampleWithBLOBs(Unknown Source)
com.prince.controller.ArticleController.list(ArticleController.java:33)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:567)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1063)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
一开始我也上网查了一下,说是Mapper文件和Mapper接口名字不对应的问题,但是我的Mapper和接口都是你想工程自动生成的,也没有这样的问题:
后面自己捣鼓一波,原来是mapperLocations里的配置没有加上classpath:
所致
修改后如下:
但是前几天做数据库实验三的时候用的也是mybatis+spring整合,没有用到springmvc,只是用了Swing做了个图形界面,配置里没有加上classpath:
,却能成功访问数据不报错,这就是个奇怪的问题了。。。(以后再研究吧)
以上是关于Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)的主要内容,如果未能解决你的问题,请参考以下文章
实践丨SpringBoot整合Mybatis-Plus项目存在Mapper时报错
实践丨SpringBoot整合Mybatis-Plus项目存在Mapper时报错
mybatis-spring-boot-starter在maven包时报错
spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext