测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>
作者:mmseoamin日期:2024-01-22

问题一:

JSON parse error: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token

at [Source: (PushbackInputStream); line: 1, column: 1]

原因:

参数字段不匹配,比如我这里写的后端接口接受的参数是数组(@RequestBody List< String> customers),但是传参又是一个json数据,没对应好(如下图

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第1张

解决方法:

数组应该这样子传

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第2张

问题二:

Content type ‘text/plain;charset=UTF-8’ not supported

测试接口时,postman:

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第3张

后端:

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第4张

只需要在请求的请求头上设置Content-Type为application/json就行

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第5张

问题三:

The error may involve defaultParameterMap

The error occurred while setting parameters

Cause: java.sql.SQLSyntaxErrorException: Duplicate column name ‘id’; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Duplicate column name ‘id’

测试接口,发起请求时候报错JSON parse error: Cannot deserialize instance of java.util.ArrayList<java.lang.Object>,在这里插入图片描述,第6张

原因:

连接了多个表都带有id,而我又为了省事直接select *,

解决方法:

要哪些数据就拿那些数据,而我只需要某一张表的字段加上其他表的几个字段就可以用select 表名.星,表名.字段获取