私の小道具クラス:
public class Props {
private static String name;
private static float price;
//normal getters and setters;
}
私のXML
<root>
<Props>
<name>Test1</name>
<ownedBy>NULL</ownedBy>
<price>1000</price>
</Props>
<Props>
<name>Test2</name>
<ownedBy>NULL</ownedBy>
<price>1000</price>
</Props>
</root>
in.readObject();
(オブジェクト入力ストリームで)2回呼び出すと、エラーが発生します:
com.thoughtworks.xstream.converters.ConversionException: Could not set field class
com.mwerner.main.Props.name : null : Could not set field class
com.mwerner.main.Props.name : null
別のプロジェクトでコードを試してみたところ、うまく機能しました。今、より大きなメイン プロジェクトで、カスタム メソッドで全体を呼び出していinitProps();
ます。なんで?