嗨,我看到了Google的XStream实现,但是我仍然得到了一个
“无法构造类,因为它没有无args构造函数”
@Test
public void testNoNoArgs() {
Car car = new Car(1, "Blue");
XStream xstream = new XStreamGae();
String s = xstream.toXML(car);
Car c = (Car) xstream.fromXML(s);
}完整的堆栈跟踪如下:http://pastebin.com/TGF6N17W
我的应用程序中与XStream相关的依赖项是:
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
<!-- XStreamGae Dependencies -->
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2-min</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>在这里可以找到XStreamGae类:
http://www.wappworks.com/2011/11/11/using-xstream-with-google-app-engine/
有办法让这件事起作用吗?
发布于 2013-04-04 14:06:19
显然,类Car应该有一个no-arg构造函数:
public Car(){}https://stackoverflow.com/questions/15802986
复制相似问题