0

嗨,我看到了XStreamGoogle App Engine 的实现,但是我仍然得到一个

“无法构造 [class],因为它没有无参数构造函数”

@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/

是否有解决方法可以使这种解决方法起作用?

4

1 回答 1

1

显然你的类Car应该有一个无参数的构造函数:

public Car(){}
于 2013-04-04T14:06:19.250 回答