简体   繁体   English

如何使用cxf-xjc-plugin从多个xsd生成pojos?

[英]How to generate pojos from multiple xsd with cxf-xjc-plugin?

I'd like to use the maven cxf-xjc-plugin plugin to java classes from xsd files. 我想将maven cxf-xjc-plugin插件用于xsd文件中的java类。 I have approx 30 xsd files, which I'd have to link explicit each of them inside xsdOptions . 我有大约30个xsd文件,我必须在xsdOptions明确地链接每个xsdOptions

Is it possible to provide wilcard matching for this plugin to generate from any xsd files found? 是否可以为此插件提供wilcard匹配,以便从找到的任何xsd文件生成?

Unfortunately, this plugin forces the developer to write the path for each XSD. 不幸的是,这个插件强制开发人员为每个XSD编写路径。 You can't use a wildcard for specifying the path to XSD files. 您不能使用通配符指定XSD文件的路径。

However, there has been an undocumented update made to the plugin that allows to specify a directory instead of a list of files. 但是,对插件进行了未记录的更新,允许指定目录而不是文件列表。 As such, if all of your XSDs are inside the same directory, you can specify this. 因此,如果所有XSD都在同一目录中,则可以指定此目录。 I tracked the changed to this email from the cxf-commits mailing list, dated July 2015, from dkulp@apache.org : 我在2015年7月的cxf-commits邮件列表中从dkulp@apache.org跟踪了此电子邮件的更改:

Convenience option for configuring the code generation from XSD files: Instead of having to explicitly list every single file using the <xsd> element, now the new <xsdDir> element can be used instead for specifying a directory. 从XSD文件配置代码生成的便捷选项:现在可以使用新的<xsdDir>元素来指​​定目录,而不必使用<xsd>元素显式列出每个文件。 From this directory all *.xsd files will be used for code generation. 从该目录中,所有*.xsd文件将用于代码生成。

This attribute is not documented but you can find it in the source code for version 3.0.5 for example. 此属性未记录,但您可以 3.0.5版的源代码中找到它。

You could then have the following configuration: 然后,您可以进行以下配置:

<xsdOption>
  <xsdDir>/path/to/directory/having/all/XSD</xsdDir>
  <!-- rest of configuration -->
</xsdOption>

Do note that, from reading the source code, the search for XSD files is not recursive: all XSD must be placed inside this directory and not into subdirectories for the plugin to find them. 请注意,通过阅读源代码,搜索XSD文件不是递归的:所有XSD必须放在此目录中,而不是放在子目录中,以便插件找到它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM