我刚才有一些XStream存储的XML文件,它们包含对RandomAccessSubList的引用,这个类在包级别之外是不可见的,并且没有默认构造函数,所以XStream抛出了这个错误:
com.thoughtworks.xstream.converters.ConversionException: Cannot construct java.util.RandomAccessSubList as it does not have a no-args constructor : Cannot construct java.util.RandomAccessSubList as it does not have a no-args constructor
---- Debugging information ----
message : Cannot construct java.util.RandomAccessSubList as it does not have a no-args constructor
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message : Cannot construct java.util.RandomAccessSubList as it does not have a no-args constructor*
Run Code Online (Sandbox Code Playgroud)
这是XML:
<customTimes class="java.util.RandomAccessSubList">
<l class="list">
<long>1302174300146</long>
<long>1302174305231</long>
<long>1302174310312</long>
Run Code Online (Sandbox Code Playgroud)
等等
我不能只为RandomAccessSubList编写一个转换器,因为它在util包之外是不可见的.如何告诉XStream忽略该属性的类,或者如何为我无法引用的类指定转换器?
提前致谢!