2017-06-12 52 views
0

如何從一個maven eclipse Jersey Rest API項目創建多個war文件?因爲我在這個項目中有多個Rest API。我想每個Rest API都有一個war文件。怎麼做?因爲我不想使用多模塊maven項目。如何在eclipse中從一個Maven球衣REST API項目創建多個war文件?

+0

Maven的普遍支持每個模塊一個單一的交付,並鼓勵通過這使它很難顏色的線之外。因此,舉例來說,如果你是項目包裝被定義爲「戰爭」,那麼,Maven可以很容易地產生單一的戰爭,如果你有多個API,並且它們都在同一個項目中,你可以通過重構來支持1每個項目的API,而不是試圖讓一個項目生成多個戰爭文件。 –

回答

0

我認爲您最好的選擇是使用Maven的executions功能(即「運行」任何插件,多次,在您的案例maven-war-plugin)。

因此,基本上你會多次運行maven-war-plugin,並且對每一次你想要進行的戰爭進行不同的配置。下面是SO採取的一個例子(你需要定製configuration部分每個execution

請注意,這被認爲是「最後手段」建設的設計,它仍然是建議使用多模塊。

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>3.0.0</version> 
    <executions> 
     <execution> 
      <id>list</id> 
      <phase>package</phase> 
      <goals> 
       <goal>war</goal> 
      </goals> 
      <configuration> 
       <warName>myProj-list.war</warName> 
       <webResources> 
        <resource> 
         <directory>src/main/webapp</directory> 
         <filtering>true</filtering> 
         <includes> 
          <include>**/*.xml</include> 
         </includes> 
        </resource> 
       </webResources> 
       <filtering>true</filtering> 
       <filters> 
        <filter>src/main/filters/list.properties</filter> 
       </filters> 
      </configuration> 
     </execution> 
     ... 
     <!-- more executions --> 
     </execution> 
    </executions> 
</plugin> 
相關問題