mybatis+springmvc:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
来源:互联网 发布:桶装水软件 编辑:程序博客网 时间:2024/05/16 11:52
在springmvc和mybatis整合开发的过程中,遇到了org.apache.ibatis.binding.BindingException: Invalid bound statement (xxx not found)这样的错误。从字面上理解这个错误很容易,就是不合法的方法和语句,也就是没找到xxx所对应包下接口中定义的方法。这个错误原因很多,有可能是很多种情况导致Mapper interface和xml映射文件的定义对应不上。
这里应该按照一定的顺序去检查自己写的代码,否则很难检查出自己的错误。
这里编辑器是eclipse。用idea开发可能还有mapper打包的问题,不详细去说。
按以下步骤一一执行:
1:检查xml文件所在的package名称是否和interface对应的package名称一一对应
2:检查xml文件的namespace是否和xml文件的package名称一一对应
3:检查函数名称能否对应上
4:去掉xml文件中的中文注释
5:随意在xml文件中加一个空格或者空行然后保存(我就是这里错误,好像不加回车和空格缓存就有问题)
一般来说到此就可以排除错误了
这里去说一下我的错误:
没加空格的映射文件:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="mapper.BookMapper"><select id="find" parameterType="string" resultType="Entity.Book">select * from Book where name like #{pattern}</select></mapper>
加了换行的映射文件:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="mapper.BookMapper"><select id="find" parameterType="string" resultType="Entity.Book">select * from Book where name like #{pattern}</select></mapper>
其实真的只是两个回车,一个报错,一个不报错。略感神奇!!
0 0
- mybatis整合springmvc时的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found
- mybatis+springmvc: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):
- 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)
- Leetcode 223 Rectangle Area
- Quartz调度器开发指南
- java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
- LeetCode 35. Search Insert Position
- hbase学习
- mybatis+springmvc:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mysql之锁表机制与死锁浅谈
- linux命令(三)
- 【Unity&加密】DLL加密文章说明
- MyBatis框架
- ST2-045 For POC
- 模拟退火算法解决01背包问题(matlab实现)
- 3.7 小结
- 2013年第四届蓝桥杯试题(Java本科B组)