错误描述: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.cyou.mrd.iostest.dao.IGameInfoDao.selectAllGame
Eclipse中运行正常,导入到IDEA中就运行出错。
解决方法:
总结一下解决方法,
1. 检查函数名是否一致
2. 检查xml文件中的namespace跟Dao的路径是否对应
3. 检查MyBatis配置文件中mapping.xml的扫描路径是否正确
4. 去掉xml文件中的中文注释
5. 在xml文件中添加一个空格或空行
使用了Maven和IDEA的情况下
6. 在pom.xml文件中配置build
<build>
...
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
然后右键项目–>Maven–>Generate Sources and Update Folders。
也可以将mapper.xml文件放到resource下,然后修改mapper.xml的注册路径。