最佳答案
我正在使用 Jackson 并且遇到了问题,当我尝试反序列化一个 Object 时,我得到了以下错误:
com.fasterxml.jackson.databind.JsonMappingException:
Can not construct instance of net.MyAbstractClass,
problem: abstract types either need to be mapped to concrete types,
have custom deserializer, or be instantiated with additional type information
我在属性方面有问题:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT, property = "@id")
@JsonSubTypes({ @JsonSubTypes.Type(value = MyAbstractClass.class, name = "MyAbstractClass") })
@ManyToOne
private MyAbstractClass object;
有人能帮帮我吗?