如何将VM参数传递给tomcat maven插件?

时间:2018-04-01 18:21:42

标签: java maven tomcat java-ee

我有一个集成测试模块,它使用pom.xml中的以下配置将项目WAR文件部署到嵌入式tomcat服务器

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <port>9090</port>
        <path>/helloworld</path>
    </configuration>
    <executions>
        <execution>
            <id>start-tomcat</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <fork>true</fork>
            </configuration>
        </execution>
        <execution>
            <id>stop-tomcat</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>shutdown</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我有两个问题:

  1. 当我通常通过IDE的“编辑配置”手动将应用程序部署到tomcat时,我指定了一些VM参数。当我执行 mvn verify 时,如何将 VM参数指定给嵌入式tomcat服务器?

  2. 当我的项目有许多模块,其中一个是集成测试时,我尝试使用类似的pom条目启动tomcat,如何指定部署哪个WAR

1 个答案:

答案 0 :(得分:1)

要指定系统属性,您可以使用systemProperties configuration中的this example

git rebase

要将特定战争部署到Tomcat,您可以使用deploy goal并使用<configuration> <systemProperties> <example.value.1>alpha</example.value.1> <example.value.2>beta</example.value.2> </systemProperties> </configuration> 配置指定文件。

warFile