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)的更多相关文章

  1. 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 ...

  2. idea 单元测试 mybatis spring-test 异常: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    因为在idea中必须在test下才能进行单元测试,所以进行单元测试时,ssm的项目会因为找不到resourece中的配置文件而报错 这里 org.apache.ibatis.binding.Bindi ...

  3. 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 ...

  4. mybatis配置时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...

  5. mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型

  6. MyBatis典型的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    XXXmapper.java(接口) XXXmapper.xml(结果集映射) //此两个文件要在统一包下,且xml中的namespace是唯一的,为了区分须写成 该xml的全路径

  7. mybatis-plus报org.apache.ibatis.binding.BindingException分析【转载】

    这个问题整整纠结了我四个多小时,心好累啊...不废话... 背景:Spring整合Mybatis 报错:org.apache.ibatis.binding.BindingException: Inva ...

  8. org.apache.ibatis.binding.BindingException【原因汇总】

    这个问题整整纠结了我四个多小时,心好累啊...不废话... 背景:Spring整合Mybatis 报错:org.apache.ibatis.binding.BindingException: Inva ...

  9. 【踩坑】遇到 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 报错

    今天在重做 iblog 客户端时,测试接口情况,发现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...

随机推荐

  1. LeetCode OJ:Search in Rotated Sorted Array(翻转排序数组的查找)

    Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...

  2. 逐步实现hash算法(基于BKDRhash函数)

    哈希(Hash)算法,即散列函数.它是一种单向密码体制,即它是一个从明文到密文的不可逆的映射,只有加密过程,没有解密过程.同时,哈希函数可以将任意长度的输入经过变化以后得到固定长度的输出.hash算法 ...

  3. zabbix安装收获-WARNING: 'aclocal-1.14' is missing on your system

    zabbix server已经安装成功了,在server端也安装了一个agent,一切OK. 在另外一台pg节点上安装zabbix agent时,报错: WARNING: 'aclocal-1.14' ...

  4. ubuntu16 sogou install

    1,下载搜狗deb文件(ubuntu16不要参考搜狗旧的安装文档): http://pinyin.sogou.com/linux/ 2,双击sogoupinyin_2.1.0.0086_amd64.d ...

  5. Suffix(hash+lcp+二分)

    题目链接: Suffix Consider n given non-empty strings denoted by s1 , s2 , · · · , sn . Now for each of th ...

  6. iOS NSRunloop

    什么是Runloop Runloop即运行循环.为什么你的APP放在那里不去动它,在某个时间点去操作它,它还会给你反馈.就是因为Runloop的存在. 总结一下,因为Runloop的存在,保证你的程序 ...

  7. Android Studio单独生成apk

    /********************************************************************* * Android Studio单独生成apk * 说明: ...

  8. 21天学通C++_Day5

    昨天停更了一天,真是羞羞啊,不过还是干了很多有意义的事的! 首先,昨天下午的时候,去参加了学校的春招!第一次参加招聘会,怕自己答不上面试官的问题,很是紧张! 和同学约的一点,结果到了发现还没开始,只能 ...

  9. erl_0021 erlang和java的内存模型比较(引用)

    原文  http://deepinmind.iteye.com/blog/2030390 我读到一篇相当相当有趣的关于Erlang VM内存管理策略的文章.它是Jesper Wilhelmsson写的 ...

  10. java编程之POI读取excel表格的内容

    07版本的excel需要另外加一个jar包.xbean.jar的jar包 读取代码模板.利用模板介绍读取excel的一些poi的api这是重点 /** * 读取excel文件 * @Title: re ...