美文网首页
feign调用接口返回值jackson反序列化异常

feign调用接口返回值jackson反序列化异常

作者: 爱的旋转体 | 来源:发表于2023-03-29 17:56 被阅读0次

    解决方案

    spring.jackson.deserialization.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT=true

    异常信息

    feign.codec.DecodeException: Error while extracting response for type [com.test.BizResult<com.test.InviteOrderResp>] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of com.test.InviteOrderResp (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value (''); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of com.test.InviteOrderResp (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('')
    at [Source: (ByteArrayInputStream); line: 1, column: 168] (through reference chain: com.test.BizResult["data"])
    at feign.AsyncResponseHandler.decode(AsyncResponseHandler.java:119)
    at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:87)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)

    http接口返回值

    {"code":102,"errorCode":null,"error_code":null,"error_message":null,"status":null,"message":"","data":"","errNo":null}
    

    feign接口

        @GetMapping(value = "/api/test")
        BizResult<InviteOrderResp> test(@RequestParam("code") String code);
    

    BizResult

    @Data
    public class BizResult<T> implements Serializable {
        private Integer code;
        private String message;
        private List<IBizCode> errorList;
        private BizFlowOperator flowOperator;
    
        private T data;
        private long total;
        private long current;
        private long pageSize;
    }
    

    InviteOrderResp

    import lombok.AllArgsConstructor;
    import lombok.Data;
    import lombok.NoArgsConstructor;
    
    import java.io.Serializable;
    import java.util.Date;
    
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class InviteOrderResp implements Serializable {
        private static final long serialVersionUID = -1L;
        private String mobile;
        private String name;
    }
    
    

    相关文章

      网友评论

          本文标题:feign调用接口返回值jackson反序列化异常

          本文链接:https://www.haomeiwen.com/subject/kowfddtx.html