【问题标题】:How to deploy war to Tomcat from child pom using maven tomcat plugin?如何使用 maven tomcat 插件从子 pom 向 Tomcat 部署战争?
【发布时间】:2016-08-05 03:09:21
【问题描述】:

我在 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。我在这里遗漏了什么吗?

【问题讨论】:

    标签: java maven tomcat


    【解决方案1】:

    我想通了。好像当我在子 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 标签中使用它

    【讨论】:

      猜你喜欢
      • 2014-01-19
      • 2012-04-14
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多