报错
maven里添加 mybatis 框架,运行 Test 测试类时出现报错如下
Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #16 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (16 > number of parameters, which is 15)
报错原因
sql 占位符和入参个数不一致,占位符数量大于入参
解决办法
因为将 xml 文件里注释里的占位符确计算在内了,删除注释即可
改成下面:
对了好几遍占位个数,原来注释掉的也算在内了!!
记录下。