Android:我可以/应该使用 "jackson-dataformat-xml" 进行 XML(取消)编组吗?



我的Android应用程序将使用XML与SPring Boot REST服务进行通信。

JAXB在Android上并不容易(或轻量级(。所以,我读到了关于使用jackson-dataformat-xml的信息。我使用(嵌套(对象列表。

我的问题:这是(取消(封送 XML 消息的首选方法吗?如果没有,安卓的好选择是什么?如果是这样,您能帮助解决以下问题吗?

JUnit 测试很容易通过。可以使用以下内容进行编译:

packagingOptions {
    pickFirst  'META-INF/license.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/MANIFEST.MF'
    exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
    exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
}
dependencies { 
    .... 
    compile 'com.fasterxml.jackson.core:jackson-core:2.1.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.1.2'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.1.2'
    compile( 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.3.0')
}

无法运行应用程序。我收到各种各样的错误,比如这些:

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.codehaus.stax2.XMLStreamLocation2$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.

编辑:与此同时,我看到简单的XML获得了良好的学分。

我现在使用的是Simple XML。这工作正常。

最新更新