java Maven jaxb 生成插件从多个目录读取 xsd 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11816085/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven jaxb generate plugin to read xsd files from multiple directories
提问by ziggy
If i have xsd file in the following directories
如果我在以下目录中有 xsd 文件
src/main/resources/xsd
src/main/resources/schema/common
src/main/resources/schema/soap
How can i instruct the maven jaxb plugin to generate jaxb classes using all schema files in the above directory? I can get it to generate the class files if i specify one of the folders but i cant get i dont know how to include all three folders.
我如何指示 maven jaxb 插件使用上述目录中的所有模式文件生成 jaxb 类?如果我指定其中一个文件夹,我可以让它生成类文件,但我无法得到我不知道如何包含所有三个文件夹。
Here is how i generate the files for one folder:
这是我为一个文件夹生成文件的方法:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
</configuration>
</plugin>
I tried adding multiple entries in the element but it just ignores all of them if i do that.
我尝试在元素中添加多个条目,但如果我这样做,它只会忽略所有条目。
Thanks
谢谢
回答by Timouyas
u can try this configuration :
你可以试试这个配置:
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>xsd/*.xsd</include>
<include>schema/*/*.xsd</include>
</schemaIncludes>
</configuration>
source : http://confluence.highsource.org/display/MJIIP/User+Guide
来源:http: //confluence.highsource.org/display/MJIIP/User+Guide
回答by khmarbaise
The plugin describes to put the schemata files into src/main/resourcesand not into subfolders. I would recommend to use the defaults of the plugin in the sense of convention over configuration. Furthermore it's important having the schemata to include the correct files including the correct folders.
该插件描述将模式文件放入src/main/resources而不是子文件夹。我建议在约定优于配置的意义上使用插件的默认值。此外,让架构包含正确的文件(包括正确的文件夹)也很重要。
The best thing in such situations is having a separate module which contains only the schemata's and maybe some supporting classes.
在这种情况下最好的办法是有一个单独的模块,它只包含模式和一些支持类。