初学者手册-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 ...
随机推荐
- 迁移到阿里云后,NTKO控件报存word 报文件存取错误,请检查网络传输。
解决办法:安装如下组件即可!
- 将VIM打造成强大的IDE
转载自:所需即所获:像 IDE 一样使用 vim 如侵犯您的版权,请联系:2378264731@qq.com --------------------------------------------- ...
- iOS 阶段学习第六天笔记(数组)
iOS学习( ...
- Frame-Relay交换机
- Objective C - 4 - 下载图片并且加载到View
#import "LoadInternetImageViewController.h" @interface LoadInternetImageViewController () ...
- caffe中的Local Response Normalization (LRN)有什么用,和激活函数区别
http://stats.stackexchange.com/questions/145768/importance-of-local-response-normalization-in-cnn ca ...
- 【排序】归并排序,C++实现
原创文章,转载请注明出处! 博客文章索引地址 博客文章中代码的github地址 # 基本思想(分治法) 归并排序中, “归”代表递归的意思,即递归的将数组通过折半的方式分离为单个数组. “ ...
- CentOS 7.4搭建Kubernetes 1.8.5集群
环境介绍 角色 操作系统 IP 主机名 Docker版本 master,node CentOS 7.4 192.168.0.210 node210 17.11.0-ce node CentOS 7.4 ...
- 博通BCM53101M以太网交换芯片原理解析
Quality of Service 服务质量 BCM53101M的QoS为每个端口提供6个内部队列以支持6种不同的流量类别(traffic class, TC).在流量拥塞的情况下,可通过拥塞管理, ...
- HDU1003 Max Sum
解题思路:最大连续和,此题多了记录的下标,具体见代码. #include<cstdio> #include<algorithm> using namespace std; #d ...