【问题标题】:maven-failsafe-plugin won't run on verify and does not find xml on failsafe:verifymaven-failsafe-plugin 在验证时不会运行,并且在故障安全上找不到 xml:验证
【发布时间】:2013-05-12 23:50:52
【问题描述】:

Maven 故障安全插件不会在我的项目上运行。如果我运行 mvn verify,则只运行surefire。如果我输入 mvn failsafe:verify 它会失败并出现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: /home/user/workspace/MyProject-Main/MyProject-IntegrationTest/target/failsafe-summary.xml (The system cannot find the path specified) -> [Help 1]

所以我基本上有同样的问题:failsafe plugin won't run on one project but will run on another -- why? 不同的是我的 pom 已经看起来像这样:

<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.14.1</version>
    <executions>
        <execution>
            <id>failsafe-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>failsafe-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

这就是解决这个家伙问题的方法。除了这个网站上的解决方案对我不起作用。有人能指出我在哪里搞砸了吗?

我还有一个问题,我想在预集成阶段使用 exec-maven-plugin 启动服务器。但是当我尝试 mvn-verify 时,它是执行的最后一件事。

【问题讨论】:

    标签: integration-testing maven-failsafe-plugin


    【解决方案1】:

    我将故障安全 pom sn-p 移到了父母 pom 中,这似乎可以解决问题。我不知道为什么。

    【讨论】:

    • 没错,这就是我发现的。在子 pom 上保持配置会导致不规则的测试执行。移到父级是有意义的
    【解决方案2】:

    刚找到这个,解决方法在这里:http://maven.apache.org/surefire/maven-failsafe-plugin/plugin-info.html

    maven-failsafe-plugin,例如与 maven-compiler-plugin 相反,不在默认的 maven 构建生命周期中。

    因此,必须尊重此标签层次结构:

    <project>
      <build>
        <pluginManagement>
          <plugins>
            <!-- For understanding only, below is the 'maven-compiler-plugin':
                 its path is 'project -> build -> pluginManagement -> plugins
                 -> plugin', because it's defaulty part of the maven build
                 lifecycle: we just 'manage' it -->
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              ..
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <!-- HERE is the 'maven-failsafe-plugin':
               its path is 'project -> build -> plugins ->
               plugin', because it's NOT defaulty part of
               the maven build lifecycle: we have to
               'define' it, and not just manage it as
               stated earlier -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            ..
          </plugin>
        </plugins>
      </build>
    <project>
    

    引用官方文档链接:“在父 POM 中定义插件版本”和“在 POM 或父 POM 中使用插件目标”。一定要注意区别。

    【讨论】:

      猜你喜欢
      • 2014-02-03
      • 2012-09-15
      • 2013-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-03
      • 1970-01-01
      • 2020-03-01
      相关资源
      最近更新 更多