小编典典

如何在Java中序列化地图以存储在Redis中?

redis

我有以下课程:

public class Document {

    public String id;
    public String date;
    public Map<String, Keyword> keywords = new HashMap<>();

}

public class Keyword {

    public String word;
    public Map<String, Document> docs = new HashMap<>();

}

我想序列化keywordsHashMap以便将其保存在Redis中。

java.io.NotSerializableException:关键字


阅读 319

收藏
2020-06-20

共1个答案

小编典典

使您KeywordDocument类实现java.io.Serializable

您要序列化的所有内容都应实现java.io.SerializableHashMap并且String默认情况下可以序列化,因此您无需为它们做任何事情。

请阅读

2020-06-20