简体   繁体   中英

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. I have approx 30 xsd files, which I'd have to link explicit each of them inside xsdOptions .

Is it possible to provide wilcard matching for this plugin to generate from any xsd files found?

Unfortunately, this plugin forces the developer to write the path for each XSD. You can't use a wildcard for specifying the path to XSD files.

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. I tracked the changed to this email from the cxf-commits mailing list, dated July 2015, from 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. From this directory all *.xsd files will be used for code generation.

This attribute is not documented but you can find it in the source code for version 3.0.5 for example.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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