org.apache.ibatis.binding.BindingException【原因汇总】
这个问题整整纠结了我四个多小时,心好累啊。。。不废话。。。
背景:Spring整合Mybatis
报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
解释:就是说,你的Mapper接口,被Spring注入后,却无法正常的使用mapper.xml的sql;
这里的Spring注入后的意思是,你的接口已经成功的被扫描到,但是当Spring尝试注入一个代理(MyBatista实现)的实现类后,却无法正常使用。这里的可能发生的情况有如下几种;
- 接口已经被扫描到,但是代理对象没有找到,即使尝试注入,也是注入一个错误的对象(可能就是null)
- 接口已经被扫描到,代理对象找到了,也注入到接口上了,但是调用某个具体方法时,却无法使用(可能别的方法是正常的)
当然,我们不好说是那种情况,毕竟报错的结果是一样的,这里就提供几种排查方法:
- mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)?
- 比如,接口名是NameMapper.java;对应的xml就应该是NameMapper.xml
- mapper.xml的命名空间(namespace)是否跟mapper接口的包名一致?
- 比如,你接口的包名是com.abc.dao,接口名是NameMapper.java,那么你的mapper.xml的namespace应该是com.abc.dao.NameMapper
- 接口的方法名,与xml中的一条sql标签的id一致
- 比如,接口的方法List<User> findAll();那么,对应的xml里面一定有一条是<select id="findAll" resultMap="**">****</select>
- 如果接口中的返回值List集合(不知道其他集合也是),那么xml里面的配置,尽量用resultMap(保证resultMap配置正确),不要用resultType
- 最后,如果你的项目是maven项目,请你在编译后,到接口所在目录看一看,很有可能是没有生产对应的xml文件,因为maven默认是不编译的,因此,你需要在你的pom.xml的<build></build>里面,加这么一段:
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
我就是坑在了第5点上,折腾了四个多小时,大家及时发现。
org.apache.ibatis.binding.BindingException【原因汇总】的更多相关文章
- Spring扫面路径配置不全导致异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 的原因
运行Junit测试类 package cn.bgodata.x.zero.service; import org.junit.Test; import org.junit.runner.RunWith ...
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): da.huying.usermanag ...
- Exception:HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
主要错误信息如下: HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache. ...
- MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.
在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.shen.mapper.UserMapper.findById
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.shen.mapper.Use ...
- mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...
- maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
ssm的项目如果在mapper.xml mapper接口 配置没问题的情况下 项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...
随机推荐
- Android Studio的技巧
1.快速添加add unimplements methods: 右键generate 2.快速添加try-catch:左边就有一个小电灯,然后可以选. 3.格式化OPTION + CMD + L ( ...
- zero to one (4)
复盘--天下武功唯快不破 There is no martial art is indefectible, while the fastest speed is the only way for lo ...
- BZOJ3196:二逼平衡树
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 浅谈\(Splay\):https://www.cnblogs.com/AKMer/p/ ...
- Python 中的 classmethod 和 staticmethod 有什么具体用途?
作者:李保银链接:https://www.zhihu.com/question/20021164/answer/18224953来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- requests.session保持会话
原文地址:https://blog.csdn.net/jyh_jack/article/details/82457953 如何使用requests后登录网站后,保持Session继续实现浏览.下载等效 ...
- C++与UnrealScript脚本交互
转自:http://m.blog.csdn.net/blog/qweewqpkn/39932499 一.c++调用uc脚本中的函数 举例: 1. 在脚本MenuManager.uc文件中实现函数: e ...
- 6 git 生成SSH公钥/私钥 查看公钥
如果没有公钥的话就生成公钥私钥: $ ssh-keygen 然后连续回车(一次是位置,两次密码)
- angular学习的一些Mark
http://www.cnblogs.com/xianrongbin/p/4104596.html http://angular-ui.github.io/
- 4.xpath注入详解
0x01 简介 XPath注入攻击是指利用XPath 解析器的松散输入和容错特性,能够在 URL.表单或其它信息上附带恶意的XPath 查询代码,以获得权限信息的访问权并更改这些信息.XPath注入发 ...
- Depth Buffer
Up until now there is only one type of output buffer you've made use of, the color buffer. This chap ...