### 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
原文地址:https://www.cnblogs.com/xyblogs/p/8724194.html