ERROR:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "status" not marked as ignorable (11 known properties: "method", "sequenceNo", "statusMessage", "timestamp", "supportMessage", "customerId", "data", "statusCode", "path", "transactionId", "_links"])
CODE:
代码:
@Data @JsonInclude(JsonInclude.Include.NON_NULL)
public class KYCScoreIndResponse {
private String customerId;
private String statusCode;
private String statusMessage;
private String supportMessage;
private String transactionId;
private KYCData data;
private String sequenceNo;
private String path;
private String method;
private String timestamp;
@JsonIgnore private HttpStatus httpStatus;
private Links _links;
}
How to solve the error i tried using @jsonproperty
of each parameter but not working
如何解决我尝试使用每个参数的@jsonproperty但不起作用的错误
更多回答
I think you have used the wrong property name somewhere: "status" != "httpStatus".
我认为您在某个地方使用了错误的属性名称:“status”!=“httpStatus”。
@TheincredibleJan Technically true, but it won't help. The problem here is using the right property name, not ignoring the property which is the only thing suggested in that question's top answers.
@他们增加了Jan严格来说是真的,但这于事无补。这里的问题是使用正确的属性名称,而不是忽略该问题的顶部答案中唯一建议的属性。
Can you explain your issue first?
你能先解释一下你的问题吗?
优秀答案推荐
If you want to apply @JsonIgnoreProperties to all class in you application then the best way it is override Spring boot default jackson object.
如果您想将@JsonIgnoreProperties应用于应用程序中的所有类,那么最好的方法是覆盖Spring引导的默认jackson对象。
In you application config file define a bean to create jackson object mapper like this.
在您的应用程序配置文件中,定义一个bean来创建像这样的jackson对象映射器。
@Bean
public ObjectMapper getObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}
Now, you don't need to mark every class and it will ignore all unknown properties.
现在,您不需要标记每个类,它将忽略所有未知的属性。
更多回答
我是一名优秀的程序员,十分优秀!