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.(MapperMethod.java:235)
	org.apache.ibatis.binding.MapperMethod.(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和接口都是你想工程自动生成的,也没有这样的问题:
Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)_第1张图片
后面自己捣鼓一波,原来是mapperLocations里的配置没有加上classpath:所致
Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)_第2张图片
修改后如下:
Spring整合Mybatis,访问数据时报错:Invalid bound statement (not found)_第3张图片
但是前几天做数据库实验三的时候用的也是mybatis+spring整合,没有用到springmvc,只是用了Swing做了个图形界面,配置里没有加上classpath:,却能成功访问数据不报错,这就是个奇怪的问题了。。。(以后再研究吧)

你可能感兴趣的:(Spring,Mybatis,踩坑日记)