Could not set parameters for mapping

错误现象:
Resolved [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='keywords', mode=IN, javaType=class java.lang.Object, 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: 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.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).]

SQL如下:

Mapper 如下
List getAllAdmins(@Param("id") Integer id, @Param("keywords") String keywords);
错误原因:
给#{keywords}多加了单引号导致。删掉单引号,错误解决。

posted @ 2024-04-16 21:55  瘦腿先生Stephen  阅读(277)  评论(0编辑  收藏  举报