java - 替换默认的 Maven 生命周期目标

标签 java tomcat maven-2

当我运行 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/

相关文章:

tomcat - 在 tomcat 7 中编码正斜杠和反斜杠?

java - 处理多平台(dev/integ/valid/prod ...)开发的最佳解决方案是什么?发货流程

java - 我应该使用哪个 Java 集合?

java - 如何在 Java 中定义字符串的结尾?

java - 如何获取目录中文件的绝对路径?

Grails 不基于 pom.xml 从 Maven 存储库中挑选 jar

plugins - Maven2 如何知道在哪里可以找到插件?

java - 如何使密文字符与明文字符相同?

java - Tomcat的webdav在Mac OS X上部署时重复401

java - Spring 事务 xml 模式