问题
Hi I saw a XStream
implementation for Google App Engine however I am still getting a
"Cannot construct [class] as it does no have a no-args constructor"
@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);
}
The complete stack trace is here: http://pastebin.com/TGF6N17W
The XStream related dependency in my application are:
<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>
The XStreamGae
class can be found here:
http://www.wappworks.com/2011/11/11/using-xstream-with-google-app-engine/
Is there a work-around to make this work-around work?
回答1:
Obviously your class Car
should have a no-arg constructor:
public Car(){}
来源:https://stackoverflow.com/questions/15802986/xstream-and-google-app-engine