Maven web項目自動部署到tomcat服務器,發佈到tomcat服務器
一、pom.xml 增加配置
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<container>
<!-- 指明使用的tomcat服務器版本 -->
<containerId>tomcat7x</containerId>
<!--指明tomcat服務器的安裝目錄 -->
<home>D:/apache-tomcat-7.0.53</home>
</container>
<configuration>
<type>existing</type>
<!--指明tomcat服務器的安裝目錄 -->
<home>D:/apache-tomcat-7.0.53</home>
</configuration>
</configuration>
<executions>
<execution>
<id>cargo-run</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
二、執行命令
1、 mvn clean install
2、即可在 D:/apache-tomcat-7.0.53/webapps 目錄下看到 對應項目名稱的 war包。
3、啓動tomcat即可。(windows: startup.bat , linux: startup.sh )
4、停止Tomcat: cargo:stop
感恩原作者:https://www.cnblogs.com/xdp-gacl/p/4054814.html