2013-04-04 45 views
3

我使用maven jaxb2插件从xsd文件生成Java类。最近我遇到了问题,我的模式文件列表geting真的很长,我把它们全部编写成逗号分隔值,并且行本身很长,恐怕将来会影响代码的可读性并成为一个错误的原因。那么,有没有解决办法写像在单独的标签文件:jaxb2 maven插件,在单独的标签中定义多个模式文件

<schemaFilesList> 
    <schemaFile>SharedResources/xsd/Common.xsd</schemaFile> 
    <schemaFile>SharedResources/xsd/Another.xsd</schemaFile> 
      .... 
</schemaFilesList> 

下面是代码,我现在:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>jaxb2-maven-plugin</artifactId> 
    <executions> 
    <execution> 
     <goals> 
     <goal>xjc</goal> 
     </goals> 
     <configuration> 
     <extension>true</extension> 
     <schemaDirectory>target/xsd</schemaDirectory> 
     <!-- I have really long list of files here, in different directories--> 
     <schemaFiles> 
      SharedResources/xsd/Common.xsd,SharedResources/xsd/Messaging/EmailService.xsd, ..... 
     </schemaFiles> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 

在此先感谢。

+1

'schemaFiles'节点支持Ant风格的文件模式,所以你可以使用'SharedResources/xsd/**/*。xsd'。这对你有帮助吗? – CAMOBAP 2013-04-04 08:22:46

回答

4

我们也有很多模式。我们只是省略<schemaFiles>元素,并让它读取<模式目录>中的所有模式。

相关问题