BindingException: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]解决方案

本文记录了在MyBatis从1.1.1更新到1.3.2后,Mapper层使用多参数时遇到的BindingException错误。详细解释了如何修改@Select注解中的参数引用,以确保代码兼容新版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天写Mapper层进行测试的时候踩了一个小坑,记录在这里。
mybatis更新到1.3.2后原来的代码报该错误:BindingException: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]

这是在引入多个(≥2)参数时出现的错误。举个例子如下:

@Select("select * from user where username=#{0} and password=#{1}")
	User findUserByUsername(String username, String password);

以上这段代码在mybatis version1.1.1下运行是没问题的,但更新至1.3.2后需要更改为:

    @Select("select * from user where username=#{arg0} and password=#{arg1}")
    	User findUserByUsername(String username, String password);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值