【问题标题】:How do I tell the maven-jaxb2-plugin to run xjc on all .xsd files in a maven dependency?如何告诉 maven-jaxb2-plugin 在 maven 依赖项中的所有 .xsd 文件上运行 xjc?
【发布时间】:2015-09-11 23:08:28
【问题描述】:

我正在使用maven-jaxb2-plugin 并且我的 .xsd 文件处于 maven 依赖项中。文档显示您在这样的 Maven 依赖项中指定 .xsd

<schema>
    <!-- Specifies a schema from the Maven artifact. -->
    <dependencyResource>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin-tests-po</artifactId>
        <!--  Version of the artifact. May be omitted.
        The plugin will then try to find the version using
        the dependencyManagement and dependencies of the project. -->
        <version>${project.version}</version>
        <!-- Path of the resource within the artifact. -->
        <resource>purchaseorder.xsd</resource>
    </dependencyResource>
</schema>

我想对依赖 .jar 文件中的所有 .xsd 文件运行 xjc。 .xsd 文件位于 .jar 文件中的不同目录中。这个我试过了

<resource>**/*.xsd</resource>

但由于此异常而失败

org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'maven:com.dg:XSD:jar::5.0.3.4!/**/*.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

有没有办法在 mvn 依赖项中指定所有位于不同目录中的 .xsd 文件?

另外,xjc 是否可以在一组 .xsd 文件上整理出一个依赖树,其中一个 .xsd 文件依赖于另一个文件,而另一个文件可能依赖于另一个文件,...?

谢谢。

【问题讨论】:

    标签: jaxb jaxb2 xjc maven-jaxb2-plugin


    【解决方案1】:

    有没有办法在 mvn 依赖项中指定所有位于不同目录中的 .xsd 文件?

    不,目前您必须指定单独的架构文件。您不需要指定所有这些,只需指定“根”。 请随时file an issue。

    另外,xjc 是否可以在一组 .xsd 文件上整理出一个依赖树,其中一个 .xsd 文件依赖于另一个文件,而另一个文件可能依赖于另一个文件,...?

    是的,XJC 递归地解决模式依赖关系。你可以编译一个大而深的模式林,I'm doing this routinely。

    【讨论】:

      猜你喜欢
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      • 1970-01-01
      • 2011-01-13
      相关资源
      最近更新 更多