如何使用maven tomcat插件从子pom向Tomcat部署war?

时间:2016-08-05 03:09:21

标签: java maven tomcat

我在pom

中有一个带有以下插件的maven项目
<plugin>
   <groupId>org.apache.tomcat.maven</groupId>
   <artifactId>tomcat7-maven-plugin</artifactId>
   <version>2.2</version>
   <configuration>
       <path>/casemanager</path>
       <update>true</update>
   </configuration>
</plugin>

当我做mvn tomcat7:run时,我的战争部署得很好。但是我在我的maven项目的一个模块中有以下配置

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>tomcat-run</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <fork>
                            true
                        </fork>
                    </configuration>
                </execution>
                <execution>
                    <id>tomcat-shutdown</id>
                    <goals>
                        <goal>shutdown</goal>
                    </goals>
                    <phase>post-integration-test</phase>
                </execution>
            </executions>
            <configuration>
                <fork>true</fork>
            </configuration>
        </plugin>

我希望tomcat在pre-integration-test阶段运行。现在,当我执行mvn verify时,它会启动服务器,但不会部署我的战争。我甚至试过提供warSourceDirectory。我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:0)

我明白了。好像当我在子pom中执行目标时,tomcat不会在同一级别的其他模块中搜索战争。我不得不使用webapp

                        <webapps>
                            <webapp>
                                <groupId>com.fico.fos.casemanager</groupId>
                                <artifactId>casemanager.ui</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <type>war</type>
                                <asWebapp>true</asWebapp>
                            </webapp>
                        </webapps>

我必须在configuration代码

中使用它