---
title: "Maven Cargo Tomcat 部署"
author: "YOUNG918"
date: "2010-11-11T15:49:55Z"
tags: []
categories: ["企业架构"]
slug: "maven-cargo-tomcat"
draft: false
lastmod: "2010-11-11T15:49:55Z"
id: 808808
url: "https://leonandjava.iteye.com/blog/808808"
---

pom.xml中&lt;build&gt;下添加如下代码：

 

```
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>0.3</version>
                        <configuration>
                            <wait>${cargo.wait}</wait>
                            <container>
                                <containerId>${cargo.container}</containerId>
                                <type>installed</type>
                                <home>${env.CATALINA_HOME}</home>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/${cargo.container}/container</home>
                                <properties>
                                    <cargo.hostname>${cargo.host}</cargo.hostname>
                                    <cargo.servlet.port>${cargo.port}</cargo.servlet.port>
                                </properties>
                            </configuration>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
           </build>
```

 

各参数如下设置，应该添加在&lt;properties&gt;中：

```
        <cargo.container>tomcat5x</cargo.container>
        <cargo.container.home>${env.CATALINA_HOME}</cargo.container.home>        
        <cargo.host>localhost</cargo.host>
        <cargo.port>8081</cargo.port>
        <cargo.wait>true</cargo.wait>
```

 

运行：mvn:install