从 JDK7 传递到 8 时的 JAXB2 模式生成语法错误



我正在尝试用Java 8构建一个Confluence插件。它在Java 7中正确构建。它使用 jaxb2-maven-plugin,其中目标为 "schemagen" 和阶段 "generate-resources" 的已定义执行之一抛出此错误:

[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:schemagen (restTypes) on project bb-team-plugin: 
        Execution restTypes of goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:schemagen failed: 
        syntax error @[1,1] in file: MY_WORKDIR/target/generated-sources/jaxb/META-INF/sun-jaxb.episode -> [Help 1]

我有的绑定文件:

<jxb:bindings jxb:version="1.0" jxb:extensionBindingPrefixes="xjc"
 xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
 xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
    <jxb:globalBindings>
      <xjc:simple />
    </jxb:globalBindings>
</jxb:bindings>

在 maven 中使用 -e 或 -X 不会抛出任何额外的有用输出,在执行配置中使用会抛出 SAXParseException 警告和与上述相同的错误。

我已经将我的sun-jaxb.episode与其他示例(如 https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-Episodes 在这个站点中)进行了比较,它具有完全相同的结构,没有任何内容看起来畸形。

知道会发生什么吗?

这可能有点

太晚了,或者不完全是你要找的,但这可能对某人有所帮助。

尝试使用 JAXB2 从带注释的类生成 XSD 时,我在项目中遇到了相同的语法错误("语法错误 @[1,1] in file:")。我相信该插件也在查看我的 xsd 文件,从而抛出 SAXParseException,所以我在 pom 中包含一个排除过滤器.xml如下所示:

                <schemaSourceExcludeFilters>
                    <myExcludes implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
                        <patterns>
                            <pattern>.xsd</pattern>
                        </patterns>
                    </myExcludes>
                </schemaSourceExcludeFilters>

更多关于这个: http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/schemagen-mojo.html

这为我做到了。我之前尝试的另一件事是从文件路径中删除空格(我的项目名称有空格),因为这似乎会产生一个尚未修复的旧错误。关于这个问题,看看:https://github.com/mojohaus/jaxb2-maven-plugin/issues/48

希望对您有所帮助!

最新更新