Feign接口调用错误信息

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)

问题原因:
在调用时返回值是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);
    }

修改后:

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

Feign的调用接口:

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

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

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

你可能感兴趣的:(代码实现,笔记,java)