得到
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "operationMessage" (class worker.lib.message.OperationMessage), not marked as ignorable (9 known properties: "packageMessage", "sourceAsset", "operation", "publishMessage", "requestId", "remixMessage", "targetAsset", "jobId", "intermediates"])
at [Source: (String)"{"operationMessage":{"sourceAsset":{"path":"/a/b/c.txt","repoId":"testId","region":"va6"},"targetAsset":{"path":"/folder4","repoId":"id2","region":"va6"},"jobId":"7c540211d1054442940211d10594426e","intermediates":false}}"; line: 1, column: 22] (through reference chain:
worker.lib.message.OperationMessage["operationMessage"])
我的OperationMessage类是
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data //generates getter and setters
public class OperationMessage {
@JsonProperty(value = "jobId")
private String jobId;
@JsonProperty(value = "operation")
private Operation operation;
@JsonProperty(value = "intermediates")
private Boolean intermediates; //for copy-move
private AssetProperties sourceAsset;
private AssetProperties targetAsset;
private PublishMessage publishMessage; //fields related to publish Operation.
private RemixMessage remixMessage; //fields related to remix Operation.
private PackageMessage packageMessage;//fields related to package Operation
private String requestId;
@Override
public String toString() {
return "OperationMessage [jobId=" + jobId + ", operation=" + operation + "]";
}
}
有人可以提出这里的问题吗?
最佳答案
您应该做的一些事情如下:
1)为类的成员变量添加获取器和设置器
2)添加默认构造函数public class OperationMessage { }
3)实施Serializable
public class OperationMessage implements Serializable
4)将@JsonIgnoreProperties(ignoreUnknown = true)
批注添加到您的POJO中