【问题标题】:tomcat7:shutdown by maventomcat7:maven关闭
【发布时间】:2014-02-07 12:38:26
【问题描述】:

我想按目标从 maven 关闭 tomcat7(Apache Tomcat Maven 插件):

mvn tomcat7:shutdown

有人可以提供一个例子吗?现在,在该目标完成后,我只有“构建成功”,但服务器继续工作。

【问题讨论】:

    标签: maven tomcat7 maven-plugin


    【解决方案1】:

    这将是因为您没有运行 嵌入式 Tomcat。

    一个例子是将 tomcat7:run 绑定到您的预集成测试阶段,这将启动嵌入在您的 Maven 构建中的 Tomcat 服务器,然后您可以将 tomcat7:shutdown 绑定到集成后测试阶段你已经运行了测试。

    如果您想通过在 Maven 中构建的 war 启动 Tomcat,那么您可以创建自己的运行配置文件。

    以下内容将起作用:

    <profiles>
             <profile>
                 <id>run</id>
                 <build>
                     <plugins>
                         <plugin>
                             <groupId>org.apache.tomcat.maven</groupId>
                             <artifactId>tomcat7-maven-plugin</artifactId>
                             <executions>
                                 <execution>
                                     <id>run-wars</id>
                                     <goals>
                                         <goal>run-war-only</goal>
                                     </goals>
                                     <phase>integration-test</phase>
                                 </execution>
                             </executions>
                             <configuration>
                                <warDirectory>theWar</warDirectory>
                                <path>/relativepath</path>
                                <systemProperties>
                                <webapps>
                                    <webapp>
                                        <groupId>${project.groupId}</groupId>
                                        <artifactId>myArtifact</artifactId>
                                        <version>${project.version}</version>
                                        <type>war</type>
                                        <asWebapp>true</asWebapp>
                                        <contextPath>myContext</contextPath>
                                     </webapp>
                                 </webapps> 
                            </configuration>
                        </plugin>
                    </plugins>
                </build>
            </profile>
    </profiles>
    

    您可以使用mvn package -Prun 运行它,然后您可以简单地使用Ctrl+C 将其关闭。

    Maven 不会关闭您机器上所有正在运行的 Tomcat 实例,这看起来像是您尝试自行运行该命令所暗示的。在这种情况下,找到你的 tomcat 并运行 shutdown.sh

    【讨论】:

      猜你喜欢
      • 2013-04-02
      • 2011-11-22
      • 2014-01-11
      • 2014-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-07
      • 1970-01-01
      相关资源
      最近更新 更多