将SPRING的版本更改为2.3.0后,无法使用javax.xml.bind.JAXBContext解组文件

问题描述

将SPRING的版本从2.1.4.RELEASE迁移到2.3.0.RELEASE之后,我遇到了一个问题。现在,当我尝试使用填充此对象所需的信息来解组简单的XML发票文件时,由于某种原因,它无法识别它们,并将它们全部设置为NULL。我正在使用的 JAXB 版本:

   <!--       Needed for namespace mapping-->
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.11</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.2.11</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>

这是移至旧的Spring版本(2.1.4.RELEASE)时的相同方法调用...如您所见,它正确映射了数据... [![在此处输入图片描述] [2]] [2]

如果某人需要一些其他信息,我将其添加

这是我用来解组数据的代码

  */
@Override
public EDIFile createEDIFile(String filename,String payload,Source source,Map<ConfigKey,Object> routeConfiguration) throws EDIException {
    Unmarshaller unmarshaller;
    try {
        unmarshaller = getContext(source).createUnmarshaller();
        Object document = unmarshaller.unmarshal(new ByteArrayInputStream(payload.getBytes()));
        if (document instanceof JAXBElement) {
            return (EDIFile) ((JAXBElement<?>) document).getValue();
        } else {
            return (EDIFile) document;
        }
    } catch (JAXBException e) {
        e.printstacktrace();
        throw new EDIException("An error occured while creating a file " + e.getMessage());
    }
}

上面的图片只是解组后加入零件时在调试器模式下显示内容

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)