问题描述
配置UserMapper.xml配置后,运行时出现
org.apache.ibatis.binding.BindingException: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]
查证后找到了解决办法,在此做个记录,仅供后来者遇此问题参考
解决方法
mybatis配置mapper.xml时传入多个参数的sql语句中的values应该用#{arg0}
<mapper namespace="com.lxk.mapper.UserMapper">
<insert id="save">
insert into user (username,password) values (#{0},#{1})
//修改后的
insert into user (username,password) values (#{arg0},#{arg1})
</insert>
<select id="findByUserName" resultType="com.lxk.model.User" parameterType="String">
select *from user where username=#{username,jdbcType=VARCHAR}
</select>
</mapper>