解决IntelliJ IDEA下 maven 运行命令 报错Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format
一、问题描述:
[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]
二、解决方案
只需要加在此参数外加单引号即可,即:mvn package '-Dmaven.test.skip=true'
。
mvn clean install package '-Dmaven.test.skip=true'
三、原因和方案
因为 IntelliJ IDEA 的终端默认使用 PowerShell 来运行命令,而在 PowerShell 下,参数 -Dmaven.test.skip=true
没有被正确地识别。
也可以选择将 IntelliJ IDEA 的终端设置成 CMD 模式(Command Prompt)