XStream和Google App Engine [英] XStream and Google App Engine

查看:117
本文介绍了XStream和Google App Engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我看到一个针对Google App Engine的 XStream 实现,但我仍然收到一个

$ b $




 <$ c无法构造[class],因为它没有无参数构造函数$ c> @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>
< groupId> xpp3< / groupId>
< artifactId> xpp3_min< / artifactId>
< version> 1.1.4c< / version>
< /依赖关系>
<! - XStreamGae Dependencies - >
< dependency>
< groupId> net.sf.kxml< / groupId>
< artifactId> kxml2-min< / artifactId>
< version> 2.3.0< / version>
< /依赖关系>
< dependency>
< groupId> xmlpull< / groupId>
< artifactId> xmlpull< / artifactId>
< version> 1.1.3.1< / version>
< /依赖关系>

XStreamGae 类可以在这里找到:



http://www.wappworks.com/2011/11/11/using-xstream-with-google-app-engine/



是否有解决此问题的方法?

解决方案显然,你的类 Car 应该有一个无参数构造函数:

  public Car(){} 


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?

解决方案

Obviously your class Car should have a no-arg constructor:

public Car(){}

这篇关于XStream和Google App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆