【问题标题】:How to create muliple war file from one Maven jersey REST API project in eclipse?如何在 Eclipse 中从一个 Maven jersey REST API 项目创建多个战争文件?
【发布时间】:2017-06-12 10:12:42
【问题描述】:

如何从一个 maven eclipse Jersey Rest API 项目创建多个战争文件?因为我在这个项目中有多个 Rest API。我希望每个 Rest API 都有一个 war 文件。怎么做?因为我不想使用多模块 maven 项目。

【问题讨论】:

  • Maven 通常支持每个模块有一个交付物,并且它通过使在这些线之外着色变得相当困难来鼓励这一点。因此,例如,如果您将项目打包定义为“战争”,那么 Maven 可以很容易地产生单一战争。如果您有多个 API,并且它们都在同一个项目中,那么通过重构以支持每个项目 1 个 API 可能比试图让一个项目生成多个 war 文件更好。

标签: eclipse rest maven eclipse-plugin


【解决方案1】:

我认为您最好的选择是使用 Maven 的 executions 功能(即多次“运行”任何插件,在您的情况下为 maven-war-plugin)。

所以基本上你“运行”maven-war-plugin 多次,并为你想要进行的每场战争进行不同的配置。下面是一个来自 SO 的示例(您需要为每个 execution 定制 configuration 部分。

请注意,这被认为是“最后的”构建设计,仍然建议使用多模块。

<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>

【讨论】:

    猜你喜欢
    • 2015-02-23
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 1970-01-01
    • 2015-10-02
    • 1970-01-01
    • 2013-03-08
    • 2015-09-19
    相关资源
    最近更新 更多