• org.apache.ibatis.binding.BindingException: Parameter ‘xxx‘ not found 总结


    阴沟翻船,任务提测之后出现低级错误
    在这里插入图片描述
    错误信息很明确,字段在mybatis解析的时候找不到。

    xml如下(已简化):

       select t.*
            from xxxx t
            <where>
                1=1
                <if test="onlyCreate != null and onlyCreate != ''">
                    and t.create_by = #{onlyCreate}
                </if>
                <if test="limitStatus != null and limitStatus.size() > 0">
                    and t.task_status in
                    <foreach collection="limitStatus" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="request.modifyDt != null ">
                    and trunc(t.modify_dt) = trunc(#{modifyDt})
                </if>
            </where>
            order by t.create_dt desc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    接口如下:

       List<xxxDto> pageInfo(@Param("request") xxx request, PageRequest pageInfo,
                                               @Param("tenantCode") String tenantCode, @Param("onlyCreate") String onlyCreate,
                                               @Param("limitStatus") List<String> limitStatus);
    
    • 1
    • 2
    • 3

    接口入参如下:

    public class xxx implements Serializable {
    
        @ApiModelProperty(value = "页数")
        private int page = 1;
    
        @ApiModelProperty(value = "页码")
        private int rows = 10;
    
        @ApiModelProperty(value = "编码")
        private String id;
    
        @ApiModelProperty(value = "开始时间")
        private Date startDate;
    
        @ApiModelProperty(value = "截止时间")
        private Date endDate;
    
        @ApiModelProperty(value = "tab页面", notes = "1 全部 2 待处理 3 已结束;默认是1")
        private String tab = "1";
    
        @ApiModelProperty(value = "结束时间")
        private Date modifyDt;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    解决办法:
    1.检查mapper接口,入参有没有对应的字段,或者有没有加对应的注解 @Param


    在这里插入图片描述
    明显有
    2.检查参数对应关系。modifyDt是在实体中的,但是写逻辑的时候,没有加@Param对应的前缀,导致无法yings


    把这个改完之后,程序正常。

    粗心大意翻大船!

  • 相关阅读:
    五、运算表达式
    【云原生】DevOps 环境搭建
    k8s中的端口hostPort、port、nodePort、targetPort
    软考 系统架构设计师系列知识点之数字孪生体(3)
    PostgreSQL 15新版本特性解读(含直播问答、PPT资料汇总)
    默认路由,直接路由,静态路由,动态路由
    电影产业的数据洞察:爬虫技术在票房分析中的应用
    AWK编程语言笔记第一章:基础语法
    修改smartbi的JVM调优
    【打开已有和新建Qt项目】
  • 原文地址:https://blog.csdn.net/fcfwang_net/article/details/125445437