windows - 无法在 Microsoft Powershell 中使用 `mvn -D` 参数运行 Maven,但可以在命令提示符下运行

标签 windows command-line powershell maven command

我正在尝试从命令行构建我们的 Web 项目,但跳过了测试。我正在使用命令 mvn clean install -Dmaven.test.skip=true .

当我从传统的黑白命令提示符(又名 DOS shell)运行该命令时,该命令有效,但是当我从“Windows PowerShell”的命令运行它时,我收到以下错误:

[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, prepar e-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, po st-clean. -> [Help 1]

是什么导致了这种差异?如何让 PowerShell 的行为像传统的命令提示符一样?

这是在 Windows 7 上运行。

最佳答案

当您遇到 PowerShell 对传递给控制台 EXE 的参数的解释问题时,请尝试使用 PowerShell Community Extensions 附带的 echoargs.exe 实用程序.使用此工具,您可以查看 PowerShell 如何向 EXE 提供参数,例如:

PS> echoargs mvn clean install -Dmaven.test.skip=true
Arg 0 is <mvn>
Arg 1 is <clean>
Arg 2 is <install>
Arg 3 is <-Dmaven>
Arg 4 is <.test.skip=true>

PS> echoargs mvn clean install '-Dmaven.test.skip=true'
Arg 0 is <mvn>
Arg 1 is <clean>
Arg 2 is <install>
Arg 3 is <-Dmaven.test.skip=true>

简答 - 使用引号 '-Dmaven.test.skip=true'

关于windows - 无法在 Microsoft Powershell 中使用 `mvn -D` 参数运行 Maven,但可以在命令提示符下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6347985/

相关文章:

php - 将一个文件夹中的所有文件和文件夹移动到另一个?

c++ - Online Compiler - 在等待输入时拦截程序并自动输入

linux - 如何从 linux 命令行获取视频文件的分辨率(宽度和高度)?

windows - 如何批量重命名包含数字和修改日期的文件?

c++ - 如何使用 system() 函数在 C++ 中存储 cmd 内存 [C++]

C# Forms Picturebox 以显示纯色而不是图像

mysql - 存储过程/函数列表 Mysql 命令行

使用 PowerShell 的 Azure blob 版本保留详细信息

用于重命名文件的 Powershell 脚本

powershell - 使用 powershell 浏览文件夹树