mybatis There is no getter for property named 'xxx' in 'class.....'
在确定该字段在entity中添加了get set方法之后,通常情况报这个错是因为mapper.xml中名称没有保持一致导致的。
<!-- 结果Map -->
<resultMap id="BaseResultMap" type="com.business.monitor.BaseEquipmentEntity">
<result property="relationId" jdbcType="INTEGER" column="f_relation_id"/>
<result property="equipmentId" jdbcType="VARCHAR" column="f_equipment_id"/>
<result property="baseId" jdbcType="VARCHAR" column="f_base_id"/>
<result property="host" jdbcType="VARCHAR" column="f_host"/>
<result property="port" jdbcType="INTEGER" column="f_port"/>
<result property="username" jdbcType="VARCHAR" column="f_username"/>
<result property="password" jdbcType="VARCHAR" column="f_password"/>
<result property="name" jdbcType="VARCHAR" column="f_name"/>
<result property="remark" jdbcType="VARCHAR" column="f_remark"/>
<result property="enterpriseId" jdbcType="VARCHAR" column="f_enterprise_id"/>
</resultMap>
<!-- 分页查询 -->
<select id="queryByPage" parameterType="com.common.vo.ListVo.ListReqVO"
resultMap="BaseResultMap">
SELECT
c.f_enterprise_id,
c.f_relation_id,
c.f_base_id,
c.f_host,
c.f_equipment_id,
d.f_name,
d.f_remark,
FROM t_base_equipment AS c INNER JOIN t_internet_things_equipment AS d
ON c.f_equipment_id = d.f_equipment_id
<where>
1=1
<if test="whereCondition!=null">
<if test="whereCondition.enterpriseId!=null">AND c.f_enterprise_id = #{whereCondition.enterpriseId,jdbcType=VARCHAR}</if>
<if test="whereCondition.relationId!=null">AND f_relation_id = #{whereCondition.relationId,jdbcType=INTEGER}</if>
<if test="whereCondition.host!=null and whereCondition.host!=''">AND f_host like CONCAT('%',#{whereCondition.host,jdbcType=VARCHAR},'%')</if>
<if test="whereCondition.name!=null and whereCondition.name!=''">AND d.f_name like CONCAT('%',#{whereCondition.name,jdbcType=VARCHAR},'%')</if>
</if>
</where>
</select>
其中
<result property="enterpriseId" jdbcType="VARCHAR" column="f_enterprise_id"/>
<if test="whereCondition.enterpriseId!=null">AND c.f_enterprise_id = #{whereCondition.enterpriseId,jdbcType=VARCHAR}</if>
//property的字段名称一致,column为数据库中字段名要一致,即例子中红色位置与红色一致,蓝色位置与蓝色一致。
//这是我在使用中遇到的问题及解决,当时名称未保持一致,出现如题的报错情况,将名称更正一致后,问题解决。