![](/img/trans.png)
[英]jaxb2-maven-plugin ignores namespace when generating xsd - Two classes have the same XML type
[英]jaxb2-maven-plugin - how to turn off recursive directory traversal when generating xsd from classes
我正在使用jaxb2-maven-plugin从jaxb注释类生成XSD。
配置看起来像这样
<execution>
<id>rest-api-execution-schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<sources>
<source>src/java/foo/rest/execution/model</source>
</sources>
<outputDirectory>${project.build.directory}/execution-api-xml-schema</outputDirectory>
</configuration>
</execution>
软件包foo / rest / execution / model包含许多类,这就是为什么我希望避免在单独的<source>
元素中列出所有它们的<source>
。 相反,我指定我希望使用单个<source>
元素包括整个src/java/foo/rest/execution/model
目录。
问题是有子软件包:
foo/rest/execution/model/builder
...包含其他未用jaxb注释的类,因此不应成为架构的一部分。 不幸的是,schemagen目标试图递归遍历foo / rest / execution / model目录,因此尝试为子目录中的类生成模式。
有办法避免这种情况吗?
您可以使用xjcSourceExcludeFilters
过滤由source
定义的source
即排除包,文件等。
例如:
<configuration>
<sources>
<source>src/java/foo/rest/execution/model</source>
</sources>
<xjcSourceExcludeFilters>
<filter implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
<patterns>
<pattern>src/java/foo/rest/execution/model/builder/*.java</pattern>
</patterns>
</filter>
</xjcSourceExcludeFilters>
...
</configuration>
如果内置过滤器支持无法满足您的需求,那么您可以通过使用自己的AbstractFilter
实现替换org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter
提供自己的实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.