我正在尝试使用 Kryo 序列化一些对象(自定义类: List> )的 List 列表。
list2D; // List<List<MyClass>> which is already produced.
Kryo k1 = new Kryo();
Output output = new Output(new FileOutputStream("filename.ser"));
k1.writeObject(output, (List<List<Myclass>>) list2D);
output.close();
到目前为止没问题,它写出没有错误的列表。但是当我尝试阅读它时:
Kryo k2 = new Kryo();
Input listRead = new Input(new FileInputStream("filename.ser"));
List<List<Myclass>> my2DList = (List<List<Myclass>>) k2.readObject(listRead, List.class);
我收到此错误:
Exception in thread "main" com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor): java.util.List
我怎么解决这个问题?