org.apache.ibatis.binding.BindingException: Parameter 'xxx' not found.


1. 情景重现

1.1 Mapper 代码

public interface DeviceFileInfoVOMapper {

    List<QueryFileDTO> selectVideoByField(String devId, Long chl,  Date startTime,  Date endTime, Pagination pagination);

}

1.2 XML 代码

  <select id="selectVideoByField"  resultMap="videoFileMap">
    SELECT file_id
    FROM t_device_file_info WHERE 1=1
    <trim>
      <if test="devId != null">
        AND dev_id=#{devId,jdbcType=VARCHAR}
      </if>
      <if test="chl != null">
        AND chl=#{chl,jdbcType=BIGINT}
      </if>
      <if test="startTime != null">
        AND start_time &gt;= #{startTime,jdbcType=TIMESTAMP}
      </if>
      <if test="endTime != null">
        AND end_time &lt;= #{endTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

1.3 错误详情

2. 解决方法

  在 Mapper 中定义的方法参数添加 @Param 注解,@Param 注解的值和xml中引用的参数名一致即可。

  @Param("devId"),则在xml中使用 #{devId}

public interface DeviceFileInfoVOMapper {

    List<QueryFileDTO> selectVideoByField(@Param("devId") String devId, @Param("chl") Long chl, @Param("startTime")  Date startTime, @Param("endTime") Date endTime, Pagination pagination);

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM