使用的是cargo-maven2-plugin插件,较为灵活的一个Deploy插件,具体配置如比上面的
tomcat-maven-plugin稍微有点儿复杂,部分还有不清楚,先写上以后再慢慢研究,配置如下:
- <build>
- <plugins>
- <plugin>
- <!-- 指定插件名称及版本号 -->
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- <version>1.0.3</version>
- <!-- 插件的Tomcat6.x配置 -->
- <configuration>
- <wait>true</wait> <!--是否说明,操作start、stop等后续操作必须等前面操作完成才能继续-->
- <container> <!-- 容器的配置 -->
- <containerId>tomcat6x</containerId> <!-- 指定tomcat版本 -->
- <type>installed</type> <!-- 指定类型:standalone, installed等 -->
- <home>E:\webServers\apache-tomcat-6.0.32-test</home> <!-- 指定Tomcat的位置,即catalina.home -->
- </container>
- <configuration> <!-- 具体的配置 -->
- <type>existing</type> <!-- 类型,existing:存在 -->
- <home>E:\webServers\apache-tomcat-6.0.32-test</home> <!-- Tomcat的位置,即catalina.home -->
- <properties> <!-- 配置属性 -->
- <cargo.tomcat.manager.url>http://localhost:8080/manager</cargo.tomcat.manager.url> <!-- 管理地址 -->
- <cargo.remote.username>tomcat</cargo.remote.username> <!-- Tomcat用户名 -->
- <cargo.remote.password>tomcat</cargo.remote.password> <!-- Tomcat密码 -->
- <cargo.tomcat.ajp.port>8009</cargo.tomcat.ajp.port> <!-- Ajp端口 -->
- </properties>
- </configuration>
- <deployer> <!-- 部署配置 -->
- <type>installed</type> <!-- 类型 -->
- <deployables> <!-- 部署设置 -->
- <deployable> <!-- 部署的War包名等 -->
- <groupId>org.test</groupId>
- <artifactId>testwebapp</artifactId>
- <type>war</type>
- <properties>
- <context>testwebapp</context> <!-- 部署路径 -->
- </properties>
- </deployable>
- </deployables>
- </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>
不详细的解释在XML当中,直接运行mvn install OK!~~