springboot mybatis使用注解形式报错Could not set parameters for mapping: ParameterMapping{property='xxx'

如果你使用的是xml文件配置mapper,并且传入了null值,则也会引发这个错误:

Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='dictionaryFilename', mode=IN, javaType=class java.lang.String, 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.sql.SQLException: 无效的列索引

解决方法:根据网上资料说,是加上jdbcType,如

#{dictionaryFilename,jdbcType = VARCHAR}

但是注解形式不是这个问题,因为#起的是一个占位符作用,而在java中字符串中$才能起到占位符作用,所以我们要将#变为$。

变为

这样解决了。

另外如果你要传入多个参数的时候,要么使用map传入,要么加上@Param注解

参考博客:https://blog.csdn.net/csdn_am/article/details/79854107

  • 14
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值