我想按目标关闭tomcat7 (插件):
mvn tomcat7:shutdown
有人能举个例子吗?现在,在完成这个目标之后,我只有“构建成功”,但是服务器继续工作。
发布于 2014-02-07 14:18:03
这将是因为您没有嵌入式Tomcat运行。
一个例子是绑定Tomcat 7:运行到您的预集成测试阶段,这将启动嵌入在Maven构建中的Tomcat服务器,然后您可以在运行测试之后将Tomcat 7:关机绑定到集成后测试阶段。
如果您想用在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。
https://stackoverflow.com/questions/21628020
复制相似问题