cargo maven plugin 部署tomcat7, 兼容 tomcat8
插件来源于下面网站
http://cargo.codehaus.org/Maven2+plugin
Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mkyong.common</groupId> <artifactId>SpringMVC</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>SpringMVC Maven Webapp</name> <url>http://maven.apache.org</url> <repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.org/nexus/content/groups/public/</url> </repository> </repositories> <properties> <spring.version>3.0.5.RELEASE</spring.version> </properties> <dependencies> <!-- Spring 3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.2.0.Final</version> </dependency> </dependencies> <build> <finalName>SpringMVC</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <!-- 指定插件名称及版本号 --> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.4.8</version> <configuration> <wait>true</wait> <!--是否说明,操作start、stop等后续操作必须等前面操作完成才能继续--> <container> <!-- 容器的配置 --> <containerId>tomcat7x</containerId> <!-- 指定tomcat版本 --> <type>installed</type> <!-- 指定类型:standalone, installed等 --> <home>D:/software/apache-tomcat-7.0.57</home> <!-- 指定Tomcat的位置,即catalina.home --> </container> <configuration> <!-- 具体的配置 --> <type>existing</type> <!-- 类型,existing:存在 --> <home>D:/software/apache-tomcat-7.0.57</home> <!-- Tomcat的位置,即catalina.home --> </configuration> <deployables> <!-- 部署设置 --> <deployable> <!-- 部署的War包名等 --> <groupId>com.mkyong.common</groupId> <artifactId>SpringMVC</artifactId> <type>war</type> <properties> <context>ROOT</context> <!-- 部署路径 --> </properties> </deployable> </deployables> <deployer> <!-- 部署配置 --> <type>installed</type> <!-- 类型 --> </deployer> </configuration> <executions> <!-- 执行的动作 --> <execution> <id>verify-deployer</id> <phase>install</phase> <!-- 解析install --> <goals> <goal>deployer-deploy</goal> </goals> </execution> <execution> <id>clean-deployer</id> <phase>clean</phase> <goals> <goal>deployer-undeploy</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
之后使用maven cargo:run 启动tomcat