无法在 Microsoft Powershell 中使用“mvn -D"参数运行 Maven,但可以在命令提示符下运行 [英] Cannot run Maven using `mvn -D` argument within Microsoft Powershell, but works in Command Prompt

查看:38
本文介绍了无法在 Microsoft Powershell 中使用“mvn -D"参数运行 Maven,但可以在命令提示符下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to build our web project from the commandline but skipping the testing. I am using the command mvn clean install -Dmaven.test.skip=true.

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

When I run the command from the traditional black & white Command Prompt (aka DOS shell) the command works, but when I run it from the command from "Windows PowerShell" I get the following error:

[错误] 未知的生命周期阶段.test.skip=true".您必须以 <plugin-prefix>:<goal> 格式指定有效的生命周期阶段或目标.或 <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<目标>.可用的生命周期阶段是:验证、初始化、生成源、流程源、生成资源、流程资源、编译,流程类,生成测试源,流程测试源,生成测试资源,流程测试资源,测试编译,流程测试类,测试,准备电子包、包、集成前测试、集成测试、集成测试后、验证、安装、部署、站点前、站点、站点后、站点部署、预清理、清理、po圣洁.->[帮助1]

造成这种差异的原因是什么?如何让 PowerShell 像传统的命令提示符一样工作?

What is causing this discrepancy and how do I get PowerShell to behave like the traditional Command Prompt?

这是在 Windows 7 上运行的.

This is running on Windows 7.

推荐答案

当您遇到 PowerShell 对要传递给控制台 EXE 的参数的解释问题时,请尝试使用 echoargs.exe 实用程序PowerShell 社区扩展.使用此工具,您可以了解 PowerShell 如何为 EXE 提供参数,例如:

When you run into problems with PowerShell's interpretation of arguments to be passed to a console EXE, try using the echoargs.exe utility that comes with the PowerShell Community Extensions. With this tool you can see how PowerShell supplies the arguments to the EXE e.g.:

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'

这篇关于无法在 Microsoft Powershell 中使用“mvn -D"参数运行 Maven,但可以在命令提示符下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆