nested exception is : Parameter ‘某字段‘ not found. Available

时间:2025-04-02 21:36:56

调接口时报错信息如下

nested exception is :  Parameter '某字段' not found. Available parameters are [arg1, arg0, param1, param2]

这个错一般出现在多个参数的方法调取中,因为Parameter '某字段' not found报错信息含义就是说嵌套异常,某字段找不到,这里可能会问,我方法里面明明传了啊,debug也查到值了啊,但是注意看接下来的报错信息:Available parameters are [arg1, arg0, param1, param2],已经很明显的指出了问题所在啊,就是说现在某字段找不到,但现在却有这两个参数可以选,明明就是字段对应不上嘛,所以现在需要怎么做应该想起来了:

在SQL语句传多个单独的参数,若不使用对象、map,在蓝企鹅文件(某)中的方法向xml传参时,就要使用@Param注解,将入参一个一个标注清楚,不然到SQL对字段拼接时,就不知道是各自对应哪一个了

public int selectIce(@Param("iceName") String iceName, @Param("iceId") String iceId);