当我运行 mvn deploy
在我的项目中有 <packaging>war</packaging>
我收到错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project store-service-impl: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
似乎默认情况下,deploy:deploy
目标绑定(bind)到 deploy
生命周期阶段。换句话说,Maven 将尝试在 deploy
时将生成的工件(在本例中为 .war 文件)部署到远程存储库。生命周期阶段运行。
在我的例子中,我想将 war 部署到远程 Tomcat 实例而不是远程 Maven 存储库。我已将以下内容添加到 pom.xml
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<!--
<executions>
<execution>
<id>deploy-tomcat</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
-->
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>http://10.60.60.60:8080/manager</cargo.remote.uri>
<cargo.remote.username>jack</cargo.remote.username>
<cargo.remote.password>secret</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
</deployer>
</configuration>
</plugin>
这在我运行 mvn cargo:deploy
时成功部署了 .war .但是,如果我将此目标绑定(bind)到 deploy
通过取消注释 <executions>
进入 Maven 生命周期阶段元素,我收到上述错误。
似乎 cargo:deploy
目标已添加到绑定(bind)到 deploy
的目标中阶段,但我想替换 deploy:deploy
绑定(bind)到 deploy
的目标生命周期阶段(默认情况下)与 cargo:deploy
目标,这可能吗?
最佳答案
您应该将 cargo 绑定(bind)到 pre-integration-test
而不是 deploy
- 然后您的故障安全测试可以在 integration-test 期间针对已部署的 war 文件运行
阶段。您将使用 mvn verify
运行测试。
关于java - 替换默认的 Maven 生命周期目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6518706/