最近遇到了一个问题,在编译Springboot项目的时候执行:
mvn clean package -Dmaven.test.skip=true
竟然报错,检查了语法也没发现问题,然后命令放到cmd窗口却成功了,报错如下:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.179 s
[INFO] Finished at: 2019-03-26T14:01:29+08: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]
解决办法:将命令改为:
mvn clean package '-Dmaven.test.skip=true'
或者不要使用PowerShell命令行模式:在cmd窗口执行mvn clean package -Dmaven.test.skip=true。
参考强大的 stackoverflow:
题外:
-DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下。
-Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类。