There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘

Use mybatis to pass in parameters when the parameter type is string, integer, etc. If the if tag is used to determine whether the parameter is empty, there is no getter for property named ‘ID’ in ‘class java.lang.integer exception will be exploded.

Solution
1. Add @ param annotation to mapper interface parameters

List<User> selectUserById(@Param(value = "id") Integer id);

2、 It can be used when there is only one string or basic type parameter in your interface_ Parameter instead of parameter

<select id="selectUserById" resultType="com.zyq.entity.User" resultMap="userMap">
        SELECT * FROM t_user
        <where>
            <if test="_parameter != null">
                AND id = #{id}
            </if>
        </where>
    </select>


Read More: