私は外部プロパティ "のcontentType" でこのクラスを持っている:ジャクソン2.5 - JsonMappingException:欠落している外部型idプロパティ
public class ContentEvent implements AbstractMessagingEvent{
@Valid
@JsonTypeInfo(include = JsonTypeInfo.As.EXTERNAL_PROPERTY, use = NAME, property = "contentType")
public final ContentValue message;
public ContentEvent(ContentValue message) {
this.message = message;
}
public ContentEvent() {
this(null);
}
public static ContentEvent example() {
return new ContentEvent(HostedFile.example());
}
}
"contentTypeのは、" 次のいずれかになります。
@JsonSubTypes({
@JsonSubTypes.Type(SecureFormSubmission.class),
@JsonSubTypes.Type(SecureFormInvitation.class),
@JsonSubTypes.Type(TextPlain.class),
@JsonSubTypes.Type(HostedFile.class),
@JsonSubTypes.Type(ExternalFile.class)
})
public interface ContentValue{
}
私は、私は次のエラーを取得する、「contentTypeの」フィールドが欠落しているJSONをデシリアライズしよう:
com.fasterxml.jackson.databind.JsonMappingException: Missing external type id property 'contentType'
私は'defaultImpl = NoClass.class'とdefaultImpl = MyOwnCustomClass 'を追加しようとしましたが、エラーはクリアされますが、結果は' contentType 'のないオブジェクトになります。
私が望むのは、デフォルトを使用するために 'contentType'フィールドがない場合です。
ありがとうございます。
私はこのプロパティを無視したくありません。私は不足している財産を補充したい。 –