关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (
来源:互联网 发布:sqlserver insert语句 编辑:程序博客网 时间:2024/04/29 16:43
关于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日志打印成功,整个人都轻松了。
原文http://blog.csdn.net/oppo5630/article/details/51351578
最近从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整合配置如下:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="mapperLocations"> <list> <value>classpath*:com/leadthing/pojo/mapping/*Mapper.xml</value> </list> </property> </bean>
但我的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节点中加入
<resources> <resource> <directory>src/man/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources>
总结
以上两种方法个人在intellij idea中亲测成功。
Junit测试通过。看着那一条变成绿色,log4j日志打印成功,整个人都轻松了。
原文http://blog.csdn.net/oppo5630/article/details/51351578
阅读全文
0 0
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)” 错误的问题。
- 关于mybatis的org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- 关于mybatis+spring的org.apache.ibatis.binding.BindingException: Invalid bound statement错误
- 关于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)
- 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):
- Android Studio使用Genymotion
- IntelliJ IDEA 14.0.2 死机重启后报前言中不允许有内容的BUG解决方法
- 不同版本的web.xml配置
- struts2 2.5使用通配符
- Java提高篇(二七)-----TreeMap
- 关于mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (
- HDU 2825 Wireless Password (AC自动机 + 状压dp)
- java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTrans
- java.lang.NoClasjava.lang.NoClassDefFoundError: com/fasterxml/jackson/core/Json
- Python 爬虫程序的定时功能与监视
- 数据结构之列表
- Spring mvc 整合Mybatis No qualifying bean found for dependency
- MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 3 无效。
- 数据库查询 报错 *****ORA-00918: 未明确定义列