JeecgBoot系列 测试接口异常Parameter ‘lists‘ not found. Available parameters are [names, param1]
Posted DATA数据猿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JeecgBoot系列 测试接口异常Parameter ‘lists‘ not found. Available parameters are [names, param1]相关的知识,希望对你有一定的参考价值。
JeecgBoot系列 测试接口异常Parameter ‘lists’ not found. Available parameters are [names, param1]
一、错误提示
根据提示可以简单看出是Parameter “lists” not found,而在我这个接口开发中,传到Mapper层的是一个list列表,而Mapper中已经使用了@Params(“names”)设置键。
"success": false,
"message": "操作失败,nested exception is org.apache.ibatis.binding.BindingException: Parameter 'lists' not found. Available parameters are [names, param1]",
"code": 500,
"result": null,
"timestamp": 1668177771433
二、排查解决
根据排查因为我已经在入参的时候通过@param绑定了,所以这里的collection也就不能写"lists",因为collection的值需要与@param绑定的参数名一致。
AccountController.java
@AutoLog(value = "测试-批量删除")
@ApiOperation(value="测试-批量删除", notes="测试-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="names",required=true) String names)
accountService.removeByNames(Arrays.asList(names.split(",")));
return Result.OK("批量删除成功!");
AccountMapper.java
removeByNames(@Param("names") List<String> names)
AccountMapper.xml
<!--批量删除-->
<delete id="removeByNames" parameterType="List">
delete from account where name in
<foreach collection="lists" item="names" open="(" separator="," close=")">
#names
</foreach>
</delete>
因为在mapper里已经绑定了"names",所以将AccountMapper.xml中批量删除语句中的collection值做修改
<!--批量删除-->
<delete id="removeByNames" parameterType="List">
delete from account where name in
<foreach collection="names" item="names" open="(" separator="," close=")">
#names
</foreach>
</delete>
再次测试已经成功
以上是关于JeecgBoot系列 测试接口异常Parameter ‘lists‘ not found. Available parameters are [names, param1]的主要内容,如果未能解决你的问题,请参考以下文章
AndroidStudio启动异常:Caused by: java.lang.IllegalArgumentException: Argument for @NotNull paramet