springboot+mybatis mapper.xml inseter 报错
nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘username’, 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 #1 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
翻译
嵌套异常为org.apache.ibatis.type。TypeException:无法设置映射参数:ParameterMapping{property=‘username’, mode=IN, javaType=class java.lang。jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}。原因:org.apache.ibatis.type。TypeException:将参数#1的非null设置为JdbcType null时出错。尝试为该参数设置不同的JdbcType或不同的配置属性。原因:. lang。ClassCastException: . lang。字符串不能转换为java.lang.Integer
解决方法
翻阅了两三个小时的资料与博客,有说xml里面有注释 - 把注释删除的,这个方法亲测有效,但是我这个我看了许久都没有发现没有注释,也有说在**#{username}里面追加上类型如 #{username,jdbcType}**,都无法解决我的问题由于本人对此没有深入了解,所以想了个简单的办法,mapper里面 insert不加parametertype,controller层也可以判断 我在这里就把parametertype删了,这样也不报错了,代码可以顺利执行