IntelliJ中执行Maven命令报错:Unknown lifecycle phase ".test.skip=true"
解决Maven install时的Unknown lifecycle phase错误
在IntelliJ中执行Maven install操作时触发错误,已尝试相关解决方案但未解决。执行的命令及报错详情如下:
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 phases 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-compile, 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
错误原因
报错提示Unknown lifecycle phase ".test.skip=true",说明Maven把.test.skip=true当成了一个生命周期阶段来解析,问题出在命令行参数的格式上:可能是-Dmaven.test.skip=true参数被意外拆分,或是PowerShell环境对参数的解析出现异常。
解决方案
- 检查命令中
-Dmaven.test.skip=true与前面的install之间是否为正常空格,排查是否存在不可见的特殊字符 - 在PowerShell环境中,尝试给参数添加引号:
mvn clean install "-Dmaven.test.skip=true" - 直接通过IntelliJ的Maven面板操作:找到项目的
install目标,勾选"Skip Tests"选项后执行,避开命令行参数的解析问题
内容的提问来源于stack exchange,提问作者Yas dev
相关产品推荐
相关产品推荐

