当前位置:   article > 正文

Feign接口调用错误信息_openfeign. error while extracting response for typ

openfeign. error while extracting response for type and content type[applica
feign.codec.DecodeException: Error while extracting response for type [java.util.List<org.xxx.xxx.system.api.entity.xxx>] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList<org.xxx.xxx.system.api.entity.xxx>` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<org.xxx.xxx.system.api.entity.xxx>` out of START_OBJECT token
 at [Source: (PushbackInputStream); line: 1, column: 1]
。。。
Caused by: org.springframework.web.client.RestClientException: Error while extracting response for type java.util.ArrayList<org.xxx.xxx.system.api.entity.xxx>`  and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Invalid JSON input: Cannot deserialize instance of `com.yxkj.netplus.yxdllapi.response.MzNoPayResponse` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.yxkj.netplus.yxdllapi.response.MzNoPayResponse` out of START_ARRAY token
 at [Source: (PushbackInputStream); line: 1, column: 244] (through reference chain: com.yxkj.netplus.netcore.result.Result["data"])
 
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Invalid JSON input: Cannot deserialize instance of java.util.ArrayList<org.xxx.xxx.system.api.entity.xxx>`  out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.yxkj.netplus.yxdllapi.response.MzNoPayResponse` out of START_ARRAY token
 at [Source: (PushbackInputStream); line: 1, column: 244] (through reference chain: com.yxkj.netplus.netcore.result.Result["data"])
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<org.xxx.xxx.system.api.entity.xxx>` out of START_ARRAY token
 at [Source: (PushbackInputStream); line: 1, column: 244] (through reference chain: com.yxkj.netplus.netcore.result.Result["data"])
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

问题原因:
在调用时返回值是Result 无法解析json错误说明返回值是出现错误
提供接口错误位置

@GetMapping("/rightHolderTree")
    public Result rightHolderTree( @RequestParam Map<String, Object> params) {
        if (StringUtils.isEmpty(params.get("Id").toString())) {
            params.put("Id", null);
        } else {
            params.put("Id", ShiroUtil.getLoginUser().getId());
        }
        List<xxx> tree = RightHolderService.queryRightHolderTree(params);
        return Result.OK(tree);
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

修改后:

@GetMapping("/rightHolderTree")
    public  Result<List<xxx>> rightHolderTree( @RequestParam Map<String, Object> params) {
        return Result.OK();
    }
  • 1
  • 2
  • 3
  • 4

Feign的调用接口:

 @GetMapping("/sys/api/rightHolderTree")
    Result<List<xxx>> rightHolderTree(@RequestParam Map<String, Object> params) ;
  • 1
  • 2

主要原因是出现在泛型上对应得实体类要有无参构造器。

希望会对出现一样的问题的您有帮助。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/813910
推荐阅读
相关标签
  

闽ICP备14008679号