fgdfg 发表于 2016-11-28 07:20:58

Mybatis-There is no getter for property named 'XXX' in 'class java.lang.String'

<select id="queryLocationIdByMediaName" parameterType="java.lang.String" resultType="cn.com.minbolg.pts.model.TblLocation">
select * from tbl_location
<where>
<if test="mediaAccountName != null">
mediaAccountName = #{mediaAccountName}
</if>
</where>
order by update_time asc
</select>

在测试时报错:There is no getter for property named 'mediaAccountName' in 'class java.lang.String'
问题分析:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.mediaAccountName值,引起报错。
解决方法:参数前添加@Param(value="mediaAccountName")

public List<TblLocation> queryLocationIdByMediaName(@Param(value="mediaAccountName") String mediaAccountName);
页: [1]
查看完整版本: Mybatis-There is no getter for property named 'XXX' in 'class java.lang.String'