org.apache.ibatis.exceptions.PersistenceException:
Error updating database. Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘name’, mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
The error may exist in com/swust/yhc/dao/UserMapper.xml
The error may involve com.swust.yhc.dao.UserMapper.addUser-Inline
The error occurred while setting parameters
SQL: insert into mybatis.user(id, name, pwd) VALUES (?,?,?);
Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘name’, mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
错误原因:select 标签里用insert语句 不用提交,但没返回值
所以直接删除parameterType="int"即可
或者
parameterType="com.swust.yhc.pojo.User"