Postman接口自测接口,控制台报错
异常
idea 控制台报错信息:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList<java.lang.Long>` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Long>` out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]
...
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Long>` out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]
以上异常信息说:Json 解析报错:无法反序列化 ArrayList 实例
Postman入参
{
"xxList": [
228269
]
}
实操图:
接口
@PostMapping(value = "/xx")
public Result<String> pushBill(@RequestBody List<Long> xxList) {
return Result.success();
}
解决办法
这里咱们注意看一下,上述方法的形参是个 java.util.List ,而我调试接口的入参却是一个java.lang.Object (这里是重点),所以会导致JSON反序列化失败:
{
"xxList": [
228269
]
}
----------------------------------------------------------
[228269]
就像这样:
感 谢
各 位
大 佬
的 阅
读,随
手 点
赞,日
薪 过
万~!
!!
|