ReflectionException:There is no getter for property named ‘xxx‘ in ‘class java.lang.xxxx‘

一、报错异常

ReflectionException:There is no getter for property named ‘xxx‘ in ‘class java.lang.xxxx‘_第1张图片

二、问题分析

  • 接口为
    ReflectionException:There is no getter for property named ‘xxx‘ in ‘class java.lang.xxxx‘_第2张图片
  • xml文件
    ReflectionException:There is no getter for property named ‘xxx‘ in ‘class java.lang.xxxx‘_第3张图片
    原因:device_type被mybatis解析时会被转换成bean字段,通过bean里面的set和get方法来映射数据库,所以需要和bean里面的字段对应。

三、解决方法

  1. 在接口处加上@Param(“deviceType”)
 xxx(@Param("deviceType")Integer deviceType);
  1. 将接口参数和xml字段改为bean里面对应的字段
 xxx(Integer deviceTypeId);
 <select id="selectApkList" parameterType="Integer" resultType="com.yj.cloudprint.device.entity.ApkEntity">
		select
			字段
		from
			表
		<trim prefix="WHERE" prefixOverrides="AND">
			<if test="deviceTypeId!=null">
				device_type=#{deviceTypeId}
			</if>
			and status=1
		</trim>
	</select>

你可能感兴趣的:(mysql,数据库,java)