简体   繁体   English

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“消息”异常

[英]com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “message” exception

please check the below code请检查以下代码

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.*;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
        "countryCode",
        "description",
        "message"
})

public class Country {

    @JsonProperty("countryCode")
    private String countryCode;
    @JsonProperty("description")
    private String description;
    @JsonIgnore
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    @JsonProperty("countryCode")
    public String getCountryCode() {
        return countryCode;
    }

    @JsonProperty("countryCode")
    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    @JsonProperty("description")
    public String getDescription() {
        return description;
    }

    @JsonProperty("description")
    public void setDescription(String description) {
        this.description = description;
    }

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(String name, Object value) {
        this.additionalProperties.put(name, value);
    }

}

below is the stackTrace下面是堆栈跟踪

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "message" (class Dialog.Api.Testing.ReferenceData.models.Country), not marked as ignorable (2 known properties: "countryCode", "description"])
     at [Source: (String)"{"message":"Success","code":"0000","traceId":"abc1234567","origin":"/reference-data/countries","details":"https://confluence.coe.dialog.lk/display/CRMREW/Error+Codes","timestamp":"2020-07-09 15:28:38","data":{"countries":[{"countryCode":"ALBVF","description":"ALBANIA"},{"countryCode":"ALG","description":"ALGERIA"},{"countryCode":"DZA","description":"ALGERIE"},{"countryCode":"AND","description":"ANDORA"},{"countryCode":"ANT","description":"ANTIGUA"},{"countryCode":"ARG","description":"ARGENTINA"}"[truncated 14184 chars]; line: 1, column: 13] (through reference chain: Dialog.Api.Testing.ReferenceData.models.Country["message"])

In your @JsonInclude You puted 3 properties.在你的@JsonInclude你放了 3 个属性。 on the other hand you don't add setter and getter to message property.另一方面,您不会将 setter 和 getter 添加到消息属性。

Duplicated with: Jackson with JSON: Unrecognized field, not marked as ignorable与: Jackson 与 JSON 重复:无法识别的字段,未标记为可忽略

There is no property with the name message at the class you mentioned.您提到的 class 中没有名称为 message 的属性。 Does something missing from your code?您的代码中是否缺少某些内容? If you're trying to put the message value inside the map so you should remove the specification of message property at the @JsonPropertyOrder .如果您尝试将消息值放入 map 中,则应删除@JsonPropertyOrder处的消息属性规范。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 解决com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - resolving com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“ g” - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “g” 对象映射器给出异常:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段 - Object Mapper giving Exception: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field Jackson 反序列化错误:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别 - Jackson deserialization error: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException 无法使用杰克逊,com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException将xml绑定到pojo:无法识别的字段 - can not bind xml to pojo using jackson, com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 引起:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“Status” - Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “Status” Java - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“”不可标记 - Java - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "" not marked as ignorable com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“user_activity” - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "user_activity"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM