There is no getter for property named xxx' in 'class java.lang.xxx'
Posted 无尽起源
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了There is no getter for property named xxx' in 'class java.lang.xxx'相关的知识,希望对你有一定的参考价值。
在xxxMapper.xml我们使用sql片段来提高sql代码的复用性,当时新手传入参数时常常出现这样的错误:
There is no getter for property named xxx‘ in ‘class java.lang.xxx‘
①出现的原因:我们实体类中有getter方法,为啥mybatis无法识别呢,原来Mybatis默认采用ONGL解析参数,所以会自动采用对象树形式来取java.lang.xxx.xxx值,所以引起报错。
②解决方法: 1)将传入参数改为_parameter这样就可以了,例如:
<sql id="whereCadtion">
<if test="_parameter">
and AREA_ID=#{_parameter}
</if>
</sql>
<sql id="Base_Column_List">
ID,DEPT_NAME,USER_NAME,JOB_NAME,DAYS,ENTRY_CORE,AREA_ID,AREA_NAME
</sql>
<select id="findAllCarEntry" parameterType="int" resultMap="resultMap">
select <include refid="Base_Column_List"/> from vie_car_entry_top
<where>
<include refid="whereCadtion"/>
</where>
</select>
2)将接口参数名说明参数值。例如:
public List methodName(@Param(value="tj") String tj);
以上是关于There is no getter for property named xxx' in 'class java.lang.xxx'的主要内容,如果未能解决你的问题,请参考以下文章
mybatis出现There is no getter for property named ...的原因及解决办法
There is no getter for property named 'NULL' in ……
Mybatis单个参数报错: There is no getter for property named
Mybatis单个参数报错: There is no getter for property named
Mybatismybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for propert(代
Mybatis单个参数的if判断(针对异常:There is no getter for property..)------mybatis的内置对象