【问题标题】:Android: can/should I use "jackson-dataformat-xml" for XML (un)marshalling?Android:我可以/应该使用“jackson-dataformat-xml”进行 XML(un)编组吗?
【发布时间】:2017-02-14 20:22:32
【问题描述】:

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

JAXB 在 Android 上并不容易(或轻量级)。因此,我阅读了有关使用 jackson-dataformat-xml 的信息。我使用(嵌套)对象列表。

我的问题:这是(取消)编组 XML 消息的首选方式吗? 如果没有,Android 有什么好的选择? 如果是,您能帮忙解决以下问题吗?

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.

编辑: 与此同时,我看到 Simple XML 得到了很好的评价。

【问题讨论】:

    标签: java android xml jackson-dataformat-xml


    【解决方案1】:

    我现在正在使用简单 XML。这工作正常。

    【讨论】:

      猜你喜欢
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 2019-11-09
      • 2017-01-11
      • 1970-01-01
      • 2016-03-02
      • 2019-08-03
      • 2021-12-23
      相关资源
      最近更新 更多