0

を使用して、MongoDB に永続化されている JSON 配列を Java オブジェクトに逆シリアル化しようとしていますJackson。以下を追加して、このポリモーフィズムを処理するために言及されている多くのチュートリアルを見つけました。

@JsonTypeInfo(use=Id.CLASS,property="_class")

Super-class。ただし、私の場合、 を変更することはできませんSuper-class。それで、変更せずにそれを解決するいくつかの解決策はありSuper-classますか? これが私のコードです:

public class User {

    @JsonProperty("_id")
    private String id;
    private List<Identity> identities; // <-- My List contains objects of an abstract class; Identity
    public User(){
        identities = new ArrayList<Identity>();
    }
    public static Iterable<User> findAllUsers(){
        return users().find().as(User.class); // Always give me the errors
    }
    /*More code*/
}

それは常に私にエラーを与えます - Can not construct instance of securesocial.core.Identity, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information

4

1 に答える 1