配置xml操作数据库时org.apache.ibatis.binding.BindingException

版权声明:非商业性使用,禁止演绎,转载请保留原文链接及作者 https://blog.csdn.net/qq_39478237/article/details/89646595

问题描述

配置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>

猜你喜欢

转载自blog.csdn.net/qq_39478237/article/details/89646595