我尝试使用 cargo-maven2-plugin 来自动化我的 WAR 模块部署以进行测试。
我想知道如何启动 tomcat 服务器(预装在我的机器中)并将我的战争自动部署到启动的服务器上?
Cargo 项目的文档提到 cargo:start 目标可以选择部署可部署:
http://cargo.codehaus.org/Maven2+plugin#Maven2plugin-gettingstarted
cargo:start 启动一个容器。该任务可以选择安装和配置容器;它还可以选择性地向其部署可部署项(WAR、EAR 等)。
但是,我不知道如何启用此选项以使其在运行 cargo:start 时部署可部署。
这是我当前的 pom 配置:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat6x</containerId>
<home>${tomcat.home}</home>
</container>
<configuration>
<type>standalone</type>
<home>target/tomcat6x</home>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>my-war</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>my-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
当我运行“mvn cargo:start”时,将启动 tomcat 服务器,但是不会部署 my-war deployable。我必须从另一个 shell 运行“mvn cargo:deploy”来部署这场战争。