5

我想web.xml在我的 Maven 项目中有两个不同的描述符文件。第一个(默认)应包含在 war 文件中以部署到应用程序服务器,第二个应用于使用tomcat7-maven-plugin:run. 我知道有参数,但它指定了我不想更改的<tomcatWebXml>Tomcat 全局。web.xml

因为jetty-maven-plugin:run我可以指定<webApp>/<descriptor><webApp>/<overrideDescriptor>。首先将 default 替换web.xml为指定文件,而第二个应用除 default 之外的指定文件内容web.xml

是否有可能如何实现相同的功能tomcat7-maven-plugin

4

1 回答 1

2

这是一个老问题,但我会在这里写下,以防其他人正在寻找。

对的,这是可能的。

您可以通过覆盖 tomcat7-maven-plugin 使用的默认(内置)war-builder 来做到这一点,即 org.apache.maven.plugins:maven-war-plugin 只需将该插件添加到您的pom.xml,以及额外的配置webXml

代码将如下所示

    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webXml>myPath/web.xml</webXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                ... other configurations here
            </configuration>
        </plugin>
        ...
    </plugins>
于 2015-09-21T08:13:27.540 回答