maven-failsafe-plugin不会在验证时运行,也不会在故障安全上找到xml:verify

use*_*505 3 integration-testing maven-failsafe-plugin

Maven故障安全插件不会在我的项目上运行.如果我运行mvn验证只有surefire运行.如果我键入mvn failsafe:验证它失败并出现以下错误:

[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]
Run Code Online (Sandbox Code Playgroud)

所以我基本上有同样的问题:failafe插件不会在一个项目上运行但会在另一个项目上运行 - 为什么? 不同的是,我的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>
Run Code Online (Sandbox Code Playgroud)

这就是这个家伙问题的解决方案.除了这个网站上的解决方案对我不起作用.有人能说出我搞砸了的地方吗?

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

小智 5

刚刚发现这个,解决方案在这里: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>
Run Code Online (Sandbox Code Playgroud)

引用官方文档链接:"在父POM中定义插件版本"和"在POM或父POM中使用插件目标".必须注意差异.