【FeignClient报错】Cannot deserialize value of type``from Object value (token `JsonToken.START_OBJECT`)

1. 问题描述

@FeignClient(name = "dataServiceQueryInterface", url = "${url}:${port}")
public interface DataServiceQueryInterface {
    @GetMapping("/dataReport/getSysAreaAllList")
    List<SysArea> getSysAreaAllList() throws Exception;
}

使用接口获取数据时报错:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception 
[Request processing failed; nested exception is feign.codec.DecodeException: 
Error while extracting response for type 
[java.util.List<com.xxx.datamatch.datacar.entity.SysArea>] and content type 
[application/json;charset=UTF-8]; nested exception is 
org.springframework.http.converter.HttpMessageNotReadableException: 
JSON parse error: Cannot deserialize value of type 
`java.util.ArrayList<com.xxx.datamatch.datacar.entity.SysArea>` 
from Object value (token `JsonToken.START_OBJECT`); 
nested exceptio
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:误信息:org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.lang.Integer from Object value (token JsonToken.START_OBJECT); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.Integer from Object value (token JsonToken.START_OBJECT) 出原因:测试时 workStatus为空,导致。 解决方法:去掉空值即可。。 引用\[2\]:"JSONparseerror:Cannotdeserializevalueoftype`java.util.ArrayList<xxx>`fromObjectvalue(token`JsonToken.START_OBJECT`);nestedexceptioniscom.fasterxml.jackson.databind.exc.MismatchedInputException:Cannotdeserializevalueoftype`java.util.ArrayList<xxx>`fromObjectvalue(token`JsonToken.START_OBJECT`)\nat\[Source:(org.springframework.util.StreamUtils$NonClosingInputStream);line:3,column:22\](throughreferencechain:cn.com.sinosoft.entity.dto.EnclosureUploadDTO\[\"enclosureList\"\])", 。 引用\[3\]:乍一看没啥问题啊,一执行的时候就误 { "code": 500, "msg": "JSON parse error: Cannot deserialize value of type `java.util.ArrayList<cn.com.sinosoft.entity.Enclosure>` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList<cn.com.sinosoft.entity.Enclosure>` from Object value (token `JsonToken.START_OBJECT`)\n at \[Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 3, column: 22\] (through reference chain: cn.com.sinosoft.entity.dto.EnclosureUploadDTO\[\"enclosureList\"\])", "data": null } 。 问题:Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJECT`) 回答: 这个误是由于在JSON解析过程中,尝试将一个对象类型的值转换为Integer类型时引发的。具体来说,误信息中的"Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJECT`)"表示在解析过程中遇到了一个对象类型的值,而期望的是一个Integer类型的值。这可能是因为在JSON中,该字段的值被误地设置为了一个对象,而不是一个整数。要解决这个问题,需要检查JSON数据中对应的字段,确保它的值是一个合法的整数,而不是一个对象。 #### 引用[.reference_title] - *1* [Cannot deserialize value of type `java.lang.Integer` from Object value (token `JsonToken.START_OBJEC](https://blog.csdn.net/weixin_44508895/article/details/130195442)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [“JSON parse error: Cannot deserialize value of type `java.util.ArrayList<XXX>` from Object value ...](https://blog.csdn.net/xiaoheihai666/article/details/127817980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值