2013-04-04 49 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>元素,並讓它讀取<模式目錄>中的所有模式。

相關問題