mybatis 如何在参数映射时正确给给参数设置javaType?

insert into t_file(rootPathId,fileName,gender) 
  values(${rootPathId},${fileName,javaType=string},'${gender}')

如上,想给fileName指定javaType为String。执行语句时报错

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'string' in 'class com.rayootech.entity.T_file'

问题出现在mybatis将string作为参数进行处理。
我的mybatis版本为3.3.0。
看Mybatis文档时对参数映射这一块貌似没有特殊的配置要求,不知道网友们有没有碰到这种情况,有的话怎么解决的?

阅读 3.8k
1 个回答

找到原因了,这里应该使用#{}而不是${}……

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进