使用Maven Cargo 插件进行远程Tomcat6的部署(二)

上一篇 / 下一篇  2012-06-06 17:29:38 / 个人分类:Maven

2)接下来配置容器的属性,详细描述如下:

 Xml代码  收藏代码

  1. <!-- 容器的属性 -->  
  2.                     <configuration>  
  3.                         <!-- 如果你在容器属性中指定类型为"installed"的话,你就必须在如下配置type==existing和重配一次安装目录-->  
  4.                         <type>existing</type>  
  5.                         <home>${catalina.home}</home>  
  6.                         <properties>  
  7.                             <cargo.tomcat.manager.url>  
  8.                             ${cargo.tomcat.manager.protocol}://${cargo.tomcat.manager.hostname}:${cargo.tomcat.manager.port}/manager  
  9.                             </cargo.tomcat.manager.url>  
  10.                             <cargo.remote.username>${cargo.tomcat.manager.username}</cargo.remote.username>  
  11.                             <cargo.remote.password>${cargo.tomcat.manager.password}</cargo.remote.password>  
  12.                             <cargo.tomcat.ajp.port>${cargo.tomcat.manager.ajp.port}</cargo.tomcat.ajp.port> <!-- ajp端口,默认8009 -->  
  13.                         </properties>  
  14.                     </configuration>  
     当然这里的属性还有很多,如果您想获知更多的参数定义,请点击Tomcat+6x

3)Cargo有部署的概念,详细操作如下:

   Xml代码  收藏代码

  1. <!-- 准备执行部署 -->  
  2.                     <deployer>  
  3.                         <!-- 类型设置必须跟容器一致 -->  
  4.                         <type>installed</type>  
  5.                         <deployables>  
  6.                              <!--在deployable中指定你要部署的webapp -->  
  7.                             <deployable>  
  8.                                  <groupId>${cargo.project.groupid}</groupId>   
  9.                                  <artifactId>${cargo.project.artifactid}</artifactId>  
  10.                                  <type>war</type>  
  11.                                  <!--如果你想重新定义Web应用的名称时设置,大多数情况下你都会定义此属性-->  
  12.                                  <properties>  
  13.                                  <context>${myproject.name}</context>  
  14.                                  </properties>  
  15.                             </deployable>  
  16.                         </deployables>  
  17.                     </deployer>  
  18.                 </configuration>  
   注:<deployalbe>中的<groupId>、<artifactId>和<type>必须定义。

4)Cargo除了可以运行"mvn cargo:deploy"这样的插件目标外,也可执行如cleaninstall这样的标准阶段目标,大多数时候我们也希望如此,详细操作如下:

  <!--运行构建的各个阶段时定义需执行的目标,每个阶段可执行多个目标 -->

<executions>

<execution>

                    <id>init-container</id><!--初始化容器时先关闭,避免JVM端口被绑定-->

                    <phase>validate</phase>

                    <goals><goal>stop</goal></goals>

                </execution>

                <!--如下的两个阶段主要用于集成测试,如果你只是部署到环境可以忽略它们 -->

                <execution>

                    <id>start-container</id>

                    <phase>pre-integration-test</phase>

                    <goals><goal>deployer-deploy</goal><!--等同于deploy,本地不支持redeploy  --></goals>

                </execution>

                <execution>

                    <id>stop-container</id>

                    <phase>post-integration-test</phase>

                    <goals><goal>deployer-undeploy</goal><!--等同于undeploy,本地不支持redeploy  --></goals>

                </execution>

                <execution><!-- 通过"install"目标部署到容器并运行-->

                    <id>verify-deploy</id>

                    <phase>install</phase>

                    <goals><goal>deployer-deploy</goal><goal>start</goal>

                    </goals>

                </execution> 

                <execution><!--通过"pre-clean"目标取消部署并关闭容器-->

                    <id>clean-undeploy</id>

                    <phase>pre-clean</phase>

                    <goals><goal>deployer-undeploy</goal><goal>stop</goal>

                    </goals>

                </execution> 

            </executions>


TAG: Cargoplugin maven Maven Maven插件 远程部署

 

评分:0

我来说两句

日历

« 2024-04-24  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 9456
  • 日志数: 12
  • 建立时间: 2011-03-08
  • 更新时间: 2012-06-06

RSS订阅

Open Toolbar