3
考慮一個簡單的Xsctream例如創建JSON出來的Bean:與西河合作,澄清需要
Bean bean = new Bean();
bean.addNames("John", "Doe");
bean.addNames("Jane", "Doe");
XStream xstream = new XStream(new JettisonMappedXmlDriver());
xstream.setMode(XStream.NO_REFERENCES);
System.out.println(xstream.toXML(bean));
結果
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jettison/mapped/Configuration
at com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver.<init>(JettisonMappedXmlDriver.java:55)
at Main.main(Main.java:12)
注意庫進口,因爲他們應該
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
And proper 個罐子包括
+1感謝,幫我呢! – Aaron 2012-05-29 17:17:30
我有jettison.jar,它在我的構建路徑,但我仍然收到相同的錯誤。 – tricknology 2013-06-11 02:19:28
檢查您是否正在引用正確的jar並且正在加載 – 2013-06-11 13:38:14