• ### Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]


    org.apache.ibatis.exceptions.PersistenceException:
    ### Error updating database. Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]
    ### The error may involve com.imp.IStudents.insertOne-Inline
    ### The error occurred while setting parameters
    ### SQL: insert into students(name,pass) values(?,?)
    ### Cause: org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2]

    mmp ,遇到这个错误弄了半天,在百度上找了半天的教程,在cdsn上看到说是有两种方法可以

    但我测试之后只有第一种方法可行

    xml文件中的插入语句不要变

    1   <insert id="insertOne" parameterType="Students">
    2        insert into students(name,age) values(#{name},#{age})
    3   </insert>

    改一下接口中的方法的参数

    1  void insertOne(@Param("name")String name,@Param("age")int age);
    IStudents.java

    测试方法如下

    1 @Test
    2     public void testInsertOne() throws Exception {
    3         SqlSession sqlSession = DataBaseManager.getSqlSession();
    4         IStudents mapper = sqlSession.getMapper(IStudents.class);
    5         mapper.insertOne("邢逸", 18);
    6         sqlSession.commit();
    7     }
    TestBasic.java
  • 相关阅读:
    php7与其他版本共存
    centos源码安装mysql5.7
    禁用composer update命令
    lumen怎么得到当前Uri的控制器、Action、路由规则
    配置lumen的log为daily模式
    laravel如何打印orm封装的sql语句
    nginx 重写URL尾部斜杠
    Laravel的Nginx重写规则--让路由支持末尾加斜线
    laravel redis存数组并设置过期时间
    openresty
  • 原文地址:https://www.cnblogs.com/xyblogs/p/8724194.html
Copyright © 2020-2023  润新知