利用maven插件cargo远程(本地)自动部署

pom.xml

利用remote方式,前提要启动好tomcat,以及设置访问tomcat的权限即可。

 运行命令:mvn cargo:redeploy

 

Java代码   收藏代码
<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>cn.gzjp.wapportal</groupId>
  <artifactId>gpas_manager</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>manager Maven Webapp</name>
  <url>http://maven.apache.org</url>
  
  <properties>
    <springframework.version>2.5.6</springframework.version>
    <junit.version>4.7</junit.version>
    <tomcat.manager>http://${tomcat.host}:${tomcat.port}/manager</tomcat.manager> 
  </properties>
  
    <profiles>  
        <profile>  
            <id>dev</id>  
            <activation>  
                <activeByDefault>true</activeByDefault>  
            </activation>  
            <properties>  
                <tomcat.host>172.31.36.214</tomcat.host>  
                <tomcat.port>8080</tomcat.port>  
                <tomcat.server>development</tomcat.server>  
                <tomcat.manager.username>admin</tomcat.manager.username>  
                <tomcat.manager.password>admin</tomcat.manager.password>  
            </properties>  
        </profile>  
    </profiles>
  
  <build>
 
    <finalName>gpas_manager</finalName>
      <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!--
            <plugin>
                 使用Cargo实现自动化部署

            
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <version>1.0.6</version>
              <configuration>
                  <container>
                      <containerId>tomcat6x</containerId>
                      <home>F:\apache-tomcat-6.0.18</home>
                  </container>
                  <configuration>
                      <type>existing</type>
                      <home>F:\apache-tomcat-6.0.18</home>
                  </configuration>
              </configuration>
              
               -->
               <!-- 
               <configuration>
                  <container>
                      <containerId>tomcat6x</containerId>
                      <type>remote </type>
                  </container>
                  <configuration>
                      <type>runtime</type>
                      <properties>
                        <cargo.remote.username>admin</cargo.remote.username>
                        <cargo.remote.password>admin</cargo.remote.password>
                        <cargo.tomcat.manager.url>
                        http://172.31.36.214:8080/manager
                        </cargo.tomcat.manager.url>
                        </properties>
                  </configuration>
              </configuration>
              
          </plugin>
        -->
        
         <plugin>  
                <groupId>org.codehaus.cargo</groupId>  
                <artifactId>cargo-maven2-plugin</artifactId>  
                 <version>1.0.6</version>
                <!--可选-->  
               <executions>  
                  <execution>  
                     <id>verify-deploy</id>  
                     <phase>pre-integration-test</phase>  
                     <goals>  
                         <goal>deployer-redeploy</goal>  
                     </goals>  
                  </execution>  
                </executions>
                <configuration>  
                   <container>  
                       <containerId>tomcat6x</containerId>  
                       <type>remote</type>  
                   </container>  
                   <configuration>  
                       <type>runtime</type>  
                       <properties>  
                           <cargo.tomcat.manager.url>${tomcat.manager}</cargo.tomcat.manager.url>  
                           <cargo.remote.username>${tomcat.manager.username}</cargo.remote.username>  
                           <cargo.remote.password>${tomcat.manager.password}</cargo.remote.password>  
                       </properties>  
                   </configuration>  
                    <deployer>  
                       <type>remote</type>  
                       <deployables>  
                         <deployable>  
                             <groupId>${groupId}</groupId>  
                               <artifactId>${artifactId}</artifactId>  
                            <type>war</type>  
                            <pingURL>http://${tomcat.host}:${tomcat.port}/cargocpc/index.html</pingURL>  
                             <properties>  
                        <!-- deployer是部署时的相关配置,这个context是用来声明工程部署后的上下文,也就是  
                                        主机地址后面的一级目录位置。这个设置在maven构建中还是很必要的。因为maven默认打出  
                                        的war包是工程名+版本号,部署时如果不设置这里的context,那上下文就变成了工程名+版本号  
                                        的形式。这会使访问变得很不方便。注意,即使你通过修改war插件中的warName也是不能达到这个  
                                        目的,因为cargo认定的默认war包名就是工程名+版本号的形式。也可以利用finalName来制定  -->
                               <context>${artifactId}</context>  
                             </properties>  
                          </deployable>  
                        </deployables>  
                    </deployer>  
                </configuration>  
            </plugin>  
      </plugins>
  </build>
  <dependencies>
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
          <groupId>com.danga</groupId>
          <artifactId>memcached</artifactId>
          <version>2.0.1</version>
          <type>jar</type>
          <scope>compile</scope>
      </dependency>
      <dependency>
          <groupId>aspectj</groupId>
          <artifactId>aspectjweaver</artifactId>
          <version>1.5.2a</version>
          <type>jar</type>
          <scope>compile</scope>
      </dependency>
      <dependency>
          <groupId>aspectj</groupId>
          <artifactId>aspectjrt</artifactId>
          <version>1.5.2a</version>
          <type>jar</type>
          <scope>compile</scope>
      </dependency>
      <dependency>
          <groupId>cglib</groupId>
          <artifactId>cglib-nodep</artifactId>
          <version>2.1_3</version>
          <type>jar</type>
          <scope>compile</scope>
      </dependency>
      <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.3.GA</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>rome</groupId>
        <artifactId>rome-fetcher</artifactId>
        <version>1.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.sawen21</groupId>
        <artifactId>rss4j</artifactId>
        <version>1.0.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

                    
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.0</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>opensymphony</groupId>
                <artifactId>quartz</artifactId>
                <version>1.6.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.extremecomponents</groupId>
                <artifactId>extremecomponents</artifactId>
                <version>1.0.1</version>
                <scope>compile</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>commons-lang</artifactId>
                        <groupId>commons-lang</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.ce.cetag</groupId>
                <artifactId>cetag</artifactId>
                <version>1.0.0</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.1</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.4</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts2-core</artifactId>
                <version>2.0.14</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.6.1</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>0.9.27</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>ant</groupId>
                <artifactId>ant</artifactId>
                <version>1.7.0</version>
                <scope>compile</scope>
            </dependency>
        
            <dependency>
                <groupId>javax.persistence</groupId>
                <artifactId>persistence-api</artifactId>
                <version>1.0</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-annotations</artifactId>
                <version>3.2.1.ga</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>3.6.1.Final</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts2-spring-plugin</artifactId>
                <version>2.0.11.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts2-codebehind-plugin</artifactId>
                <version>2.0.11.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts2-tiles-plugin</artifactId>
                <version>2.0.11.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.1.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
  </dependencies>
</project>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值