初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)
1、参数绑定失败
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'msgs3' not found. Available
parameters are [msgs, param1]
相关信息
<insert id="insertBatch">
INSERT INTO t_user
(id, name, del_flag)
VALUES
<foreach collection ="msgs3" item="user" separator =",">
(#{user.id}, #{user.name}, #{user.delFlag})
</foreach >
</insert>
//Mapper类
public interface UserMapper {
public void insertBatch (List<User> users);
}
分析思路
经过测试发现错误是从map.xml文件报出来的,也就是说,系统是可以读到xml文件的,但是通过xml文件读取对应的参数msgs3时报错。即,问题出在map.java上面。但是,检查了命名,并没有相关问题。
解决方案
既然是绑定的问题,那么问题肯定不是在xml文件上,就是在对应的map的java方法上。所以,有两种解题方法。
值得注意的是:指定了传参名称以后,默认值就会失效
1、修改xml文件
通过测试发现,foreach 中的collection貌似默认值为 list,当不指定传参的名称时,可以直接使用。
<insert id="insertBatch">
INSERT INTO t_user
(id, name, del_flag)
VALUES
<foreach collection ="list" item="user" separator =",">
(#{user.id}, #{user.name}, #{user.delFlag})
</foreach >
</insert>
2、修改Mapxx.java中的方法参数
//Mapper类
public interface UserMapper {
public void insertBatch (@Param("msgs") List<User> users);
}
初学者手册-MyBatis踩坑记(org.apache.ibatis.binding.BindingException)的更多相关文章
- IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.User ...
- idea 单元测试 mybatis spring-test 异常: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
因为在idea中必须在test下才能进行单元测试,所以进行单元测试时,ssm的项目会因为找不到resourece中的配置文件而报错 这里 org.apache.ibatis.binding.Bindi ...
- Mybatis笔记二:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.dao.N ...
- mybatis配置时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...
- mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型
- MyBatis典型的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
XXXmapper.java(接口) XXXmapper.xml(结果集映射) //此两个文件要在统一包下,且xml中的namespace是唯一的,为了区分须写成 该xml的全路径
- mybatis-plus报org.apache.ibatis.binding.BindingException分析【转载】
这个问题整整纠结了我四个多小时,心好累啊...不废话... 背景:Spring整合Mybatis 报错:org.apache.ibatis.binding.BindingException: Inva ...
- org.apache.ibatis.binding.BindingException【原因汇总】
这个问题整整纠结了我四个多小时,心好累啊...不废话... 背景:Spring整合Mybatis 报错:org.apache.ibatis.binding.BindingException: Inva ...
- 【踩坑】遇到 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 报错
今天在重做 iblog 客户端时,测试接口情况,发现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...
随机推荐
- 在关于原生js获取getAttribute如果是src的一点注意事项
最近抽空把seajs看完了 他们在fix代码的时候,写明在某浏览器下的情况和官方文档出处,这样有据可查.太赞了 顺便把我想要这段摘出来 可以直接dom.src,但是在ie6-7中是不支持的,并且在ge ...
- java中+=详解 a+=b和a=a+b的区别
short a=10; a+=4; System.out.println(a); 1.第一段代码的输出结果为14.执行流程是首先声明变量,判断赋给变量的初始值是否在short类型范围内,如果在则进行强 ...
- jquery设置控件位置的方法
纯JS写法,代码如下: document.getElementById("child").style.left="800px";document.getElem ...
- Linux网络编程IPv4和IPv6的inet_addr、inet_aton、inet_pton等函数小结
知识背景: 210.25.132.181属于IP地址的ASCII表示法,也就是字符串形式.英语叫做IPv4 numbers-and-dots notation. 如果把210.25.132.181转换 ...
- 使用treemap 遍历map参数
遍历格式 XXX=123&XXX=456.....参数为map treemap是一个有序的key-value集合,它是通过红黑树实现的 TreeMap<String, String> ...
- 熟悉linux命令
<鸟哥的linux私房菜>这本书终于看到了敲命令行这块了,有点小激动,打开虚拟机,开始~~~敲!!! 登录界面,用户名密码~~~ 登录成功,下面开始熟悉一下,linux的常见命令了: li ...
- ubuntu16 chrome install
1,download chrome.deb from : https://www.google.com/chrome/index.html 2,double click chrome.deb and ...
- 基于tensorflow的增强学习
可以通过下面的连接查看这个项目工程: https://github.com/reinforceio/tensorforce 通过这遍文章来了这个项目的使用: https://reinforce.io/ ...
- [Python] 项目打包发布
一.setuptools - 官方文档: Building and Distributing Packages with Setuptools- 中文文档: Python包管理工具setuptools ...
- Python timedelta
datetime.timedelta对象代表两个时间之间的的时间差,两个date或datetime对象相减时可以返回一个timedelta对象. 构造函数: class datetime.time ...