出现 org.apache.ibatis.binding.BindingException 异常的原因及解决方法
2017-09-09 18:36
1396 查看
1 异常描述
在对数据库表中现有敏感信息(例如姓名、手机号、身份证号、银行卡号等)进行加密处理的时候,报出如下错误:2 异常分析
通过观察上图中被标记出来的异常信息,我们可以知道org.apache.ibatis.binding.BindingException: Invalid bound statement(not found): com.XXX.router.dao.RouterProviderEntityDao.query4encrypt
此异常,为:ibatis 无效绑定异常。
我们知道 MyBatis 源自于 ibatis,在流行的 SSM 框架中,Mybatis 常被用于持久化层,说白了,就是保存数据,负责将数据持久化(插入)到数据库。在常见的 Web 项目中,我们又将其划分为 Dao 层、Service 层、Biz 层和 Facade 层,其中 Dao 层就是负责和数据库进行交互的,而交互的方式就是用 Mapper 文件进行数据库表的映射,并到 Dao 层建立与 Mapper 文件中 SQL 语句对应的函数。
现在回过头看这个异常,它发生在
router.dao.RouterProviderEntityDao.query4encrypt这个地方,其中
RouterProviderEntityDao表示 Dao 层,
query4encrypt是 Dao 层中与 Mapper 文件对应的方法名。而且,这个异常为
BindingException,绑定异常,那么很有可能就是 Mapper 文件中 SQL 的 id 名与 Dao 层中的函数名不一致。
3 解决方法
在异常分析之后,查看 Mapper 文件中 SQL 的 id 名与 Dao 层中的函数名是否一致,经过检查,发现两者确实不一致,其中 SQL 的 id 名为query4Encrypt而 Dao 层中的函数名为
query4encrypt,既然我们已经知道了发生异常的原因,那么统一两者之后,即可解决此异常。
温馨提示:此案例为个性,异常是共性。
相关文章推荐
- IDEA的maven项目出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- 出现 org.apache.tomcat.util.bcel.classfile.ClassFormatException 异常的原因及解决方法
- 出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的解决方法
- 出现 org.apache.tomcat.xxx.ClassFormatException: Invalid byte tag in constant pool: 15 异常的原因及解决方法
- 出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的解决方法
- 关于Service方法调用时出现org.apache.ibatis.binding.BindingException错误的可能原因
- SSM框架之:org.apache.ibatis.binding.BindingException异常的各原因总结
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- 关于一些mybatis异常的原因:org.apache.ibatis.binding.BindingException: Parameter 'status' not found.
- eclipse里报org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法
- 解决mapper绑定异常:nested exception is org.apache.ibatis.binding.BindingException
- IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 异常解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- POI操作excel2007 出现异常 java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlOptions 解决方法
- 出现 org.springframework.beans.factory.BeanCreationException 异常的原因及解决方法
- 异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- MyBatis笔记----报错:Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)异常解决
- org.apache.cxf.binding.soap.SoapFault: Unexpected wrapper element 出现命名空间不一致问题,解决方法
- org.apache.ibatis.binding.BindingException【原因汇总】