2017-06-12 23 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> 
相关问题