Maven 错误“未知生命周期阶段“.test.skip=true”.....”

问题描述 投票:0回答:3

当我尝试安装maven时,我在intellij中收到此错误,我尝试了此处提出的所有解决方案“https://stackoverflow.com/questions/5074063/maven-error-failure-to-transfer”,但它不起作用

PS C:\Users\stagiaire1\Desktop\Vgc\vgc-backend>  mvn clean install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.dzadvisory:bankapp >-----------------------
[INFO] Building bankapp 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.344 s
[INFO] Finished at: 2022-09-21T16:51:00+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phas
es are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-com
pile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]   
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
java maven
3个回答
29
投票

这是因为 PowerShell 将

-
解释为 PowerShell 参数。 (您的终端在第一行显示
PS

因此,您应该使用

--%
转义 PowerShell 参数,例如

mvn clean install --% -Dmaven.test.skip=true

2
投票

您可以改用此命令。

mvn clean install -DskipTests 

参考文档 - Maven CheatSheet


0
投票

无法将此放在评论中,没有足够的代表。

这里很少有东西,下面描述的操作属于 Maven Surefire 插件,您需要确保它位于 pom 内的构建条目中

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>x.x.x</version>
      <configuration>
        <skipTests>${skipTests}</skipTests>
      </configuration>
    </plugin>
  </plugins>
</build>

现在您将有三个选项来跳过测试。

  1. 正如您提到的使用 -Dmaven.test.skip 这既不会运行,也不会编译任何测试,这意味着任何依赖于可用测试工件的测试都将失败
  2. 您可以使用 -DskipTests 它将编译但不运行您的测试,这意味着任何依赖于测试工件的内容都将能够继续进行
  3. 您可以使用上面声明的配置属性(skipTests),该属性可以在您的pom属性中设置
© www.soinside.com 2019 - 2024. All rights reserved.