Mybatis异常_03_Invalid bound statement (not found)
一、异常信息
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hand.hec.nghec.sys.mapper.SysServiceMapper.selectService
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy169.selectService(Unknown Source)
at com.hand.hec.nghec.sys.service.impl.SysServiceServiceImpl.select(SysServiceServiceImpl.java:26)
at com.hand.hec.nghec.sys.service.impl.SysServiceServiceImpl.select(SysServiceServiceImpl.java:1)
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 com.hand.hap.core.impl.ServiceExecutionAdvice.invoke(ServiceExecutionAdvice.java:169)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
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.$Proxy170.select(Unknown Source)
at com.hand.hap.system.controllers.BaseController.query(BaseController.java:68)
二、异常原因
一般的原因是Mapper interface和xml文件的定义对应不上,
需要检查包名,namespace,函数名称等能否对应上,
需要比较细致的对比,我经常就是写错了一两个字母搞的很长时间找不到错误
三、异常解决过程
1.常见解决方法
出现这个错误时,按以下步骤检查一般就会解决问题:
1:检查xml文件所在的package名称是否和interface对应的package名称一一对应 2:检查xml文件的namespace是否和xml文件的package名称一一对应 3:检查函数名称能否对应上 4:去掉xml文件中的中文注释 5:随意在xml文件中加一个空格或者空行然后保存
一般来说到此就可以排除错误了
2.我的原因与解决方法
(1)原因
原因还是因为Mapper interface和xml文件的定义对应不上
这是因为我一个web工程依赖了两个jar工程,而这两个jar工程 mapper.xml文件的目录结构相似,并且映射路径也相同,这导致mybatis只扫描了其中一个jar工程的xml,而不扫描另一个的。
applicationContext.xml

jar工程1目录:

jar工程2目录:

(2)解决方法
修改applicationContext.xml 中 mapper文件映射路径:

写成两个就可以了
(3)存疑
如上述配置文件中,mybatis 一个 value 只扫一个工程的。 所以要为每个工程单独配置一个value.
四、参考资料
1.mybatis绑定错误-- Invalid bound statement (not found)
Mybatis异常_03_Invalid bound statement (not found)的更多相关文章
- Mybatis异常_01_Invalid bound statement (not found)
异常信息:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.taotao.map ...
- 解决Mybatis的invalid bound statement (not found)异常
使用Maven构建SSM时, 需要在pom.xml中配置一些信息, 否则mapper.xml就无法被扫描到, 程序就会抛invalid bound statement (not found)异常 解决 ...
- mybatis-plus 异常 Invalid bound statement (not found)
最近吧项目中添加使用了mybatis-plus,发现操作sql的时候出现异常: Invalid bound statement (not found) ,异常位置位于mybatis-plus的jar中 ...
- mybatis:Invalid bound statement (not found)
[常规解决办法] 如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因 ...
- MyBatis错误--Invalid bound statement (not found)
今天在开发项目的时候使用MyBatis发生错误:Invalid bound statement (not found) 具体错误信息: org.springframework.beans.factor ...
- mybatis错误Invalid bound statement (not found) 的解决办法
<!-- IDEA需要添加一下内容,否则无法找到mapper --> <build> <resources> <resource> <direct ...
- myBatis中Invalid bound statement (not found)错误
环境:Idea.ssm.maven 由于使用maven的原因,maven不会扫描到mapper的xml文件所以会出现此类问题. 每次走到mapper方法时就抛异常:Invalid bound stat ...
- mybatis 报Invalid bound statement(not found) 和 Property 'mapperLocations' was not specified or not matching resources found
排除问题的步骤: 1.首先检查mapper文件和mapper接口的文件名是否相等. 2.pom.xml是否把xml排除了,这样写就会src/main/java下所有的Mybatis的xml文件都删除, ...
- mybatis BindingException: Invalid bound statement (not found)
错误截图 解决措施 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的. 通常我们在配置SqlSessionFactory时会有如配置 <!-- 配置Sq ...
随机推荐
- Odoo11 新功能 : 栏位隐藏
Odoo11增加了一个 新的 modifier-. 先上 前端框架代码 invisible / readonly / required 这几个 是经常在用的, column_invis ...
- Android · 获取网络图片
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import j ...
- (三)初识jQuery
进入jQuery官网:http://jquery.com/ 点击Download jQuery v3.1.1--->下载最新版本的jQuery版本--->放到你需要引入jQuery的文件中 ...
- SQL存在一个表而不在还有一个表中的数据
select a.id,a.oacode,a.custid,a.custname,a.xsz,a.salename,a.communicationtheme,a.communicationproper ...
- Objective-C 执行AppleScript脚本
在Objective-C里事实上也能够执行AppleScript 第一种方式是Source 将脚本写到变量字符串里 NSAppleEventDescriptor *eventDescriptor = ...
- Struts2学习一----------Struts2的工作原理及HelloWorld简单实现
© 版权声明:本文为博主原创文章,转载请注明出处 Struts2工作原理 一个请求在Struts2框架中的处理步骤: 1.客户端初始化一个指向Servlet容器(例如Tomcat)的请求 2.这个请求 ...
- 05 redis中的Setbit位图法统计活跃用户
一:场景=>>>长轮询Ajax,在线聊天时,能够用到 Setbit 的实际应用 场景: 1亿个用户, 每个用户 登陆/做任意操作 ,记为 今天活跃,否则记为不活跃 每周评出: 有奖活 ...
- The Gray World Assumption
Color Constancy 色彩恒常性(2)The Gray World Assumption act=qbbkrzydb_20150408_01" style="line-h ...
- hadoop 相关工具访问端口(转)
原文:http://www.tuicool.com/articles/BB3eArJ hadoop系统部署时用到不少端口.有的是Web UI所使用的,有的是内部通信所使用的,有的是监控所使用的.实际系 ...
- 限制UITextView的字数和字数监控,表情异常的情况和禁用表情
限制UITextView的字数和字数监控,表情异常的情况和禁用表情 3523FD80CC4350DE0AE7F89A8532B9A8.png 因为字数占一个字符,表情占两个字符.你要是限制15个字 ...