关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
来源:互联网 发布:window网络编程 编辑:程序博客网 时间:2024/04/29 22:25
关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
最近从eclipse转到intellij idea,确实比eclipse好用太多,但是也是各种不熟悉,导致了很多问题,本来搭好的maven+ssm框架在eclipse上能用,迁移到idea中是各种问题,一一解决之后就剩下这个问题。org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) : org.dao.UserDao.selectByPrimaryKey,意思是我的mapper和dao的映射和接口绑定有问题。
我的spring和mybatis整合配置如下:
但我的mapper和dao中是一一对应的,所以我的问题不在这儿。
Junit测试一直是红色的一条,这个问题让我头疼,网上看了很多资料最后发现是intellij idea的问题,在eclipse中把mapper的xml文件放到src代码目录下是可以一起打包进classes的,而在新版intellij idea中是不会一起打包,就会导致找不到xml报错。
- 首先确保xml中的namespace配置是你的接口全类名,而不是包名!
- 确认dao接口中的方法,和xml中一一对应,返回类型,参数都正确。
解决方法
第一种,由于idea默认是不打包src中的xml文件,所以在eclipse中你可以把xml放到src中没有问题,但是在idea中,你把mapper的xml文件放到resources资源中就可以正常访问!
第二种 在maven配置maven对资源文件的访问,具体做法:在pom中,build节点中加入
总结
以上两种方法个人在intellij idea中亲测成功。
Junit测试通过。看着那一条变成绿色,log4j日志打印成功,整个人都轻松了。
文章为个人总结,只是想给遇到相同问题的朋友一个帮助,如有老司机觉得不对的,请指出,欢迎大家一起交流。
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题
- 关于org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误问题
- mybatis整合springmvc时的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found
- 关于mybatis的org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- 关于mybatis的org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Mybatis错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis的 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 报错。
- mybatis的org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 软件版本号说明
- 原码, 反码, 补码 详解
- 如何使用array资源文件中定义的资源数组
- 设计模式之状态模式
- ASP.NET Web API 简介
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
- BaseActivit、BaseFragment、basepager
- Java构建工具:Ant vs Maven vs Gradle
- css头尾固定中间高度自适应布局
- UVa-156 Ananagrams(map映射)
- 给HR的20条建议,针针见血!
- Android自定义View(1):对话框-Dialog
- unity Character Controller 参数
- VC/多字节字符集和unicode宽字符集