错误"执行maven命令后,您指定的目标需要执行项目,但此目录中没有POM"

Adr*_*ian 106 maven-3

我有一个pom.xmlin C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\sources\pom.xml和我执行:

mvn install:install-file -DgroupId=es.mityc.jumbo.adsi -DartifactId=xmlsec-1.4.2-ADSI -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\core\xmlsec-1.4.2-ADSI-1.0.jar
Run Code Online (Sandbox Code Playgroud)

但是它返回了以下错误:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.310s
[INFO] Finished at: Thu May 02 16:48:29 COT 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (C:\Users\AArmijos). Please verify you invoked Maven from the
 correct directory. -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

有人可以解释它失败的原因吗?

Adr*_*ian 161

此链接有助于:https://stackoverflow.com/a/11199865/1307104

我通过为每个参数添加引号来编辑我的命令,如下所示:

mvn install:install-file "-DgroupId=org.mozilla" "-DartifactId=jss" "-Dversion=4.2.5" "-Dpackaging=jar" "-Dfile=C:\Users\AArmijos\workspace\componentes-1.0.4\deps\jss-4.2.5.jar"

它奏效了.

  • 谢谢你 - 来自MVN的错误信息是_rubbish_! (26认同)
  • 从什么时候开始我需要报价?我现在很困惑,终于找到了这样一个垃圾错误消息的答案,我感到很欣慰...... (5认同)
  • 如果您使用的是 powershell,您可以直观地看到 PowerShell 如何在命令行上用颜色分隔参数,或者通过在命令前面添加“echo”来分隔参数。就像“echo mvn install:安装文件...”。 (4认同)
  • 发生这种情况是因为文件夹路径中有空格。添加引号可以解决问题,或者您可以只重命名包含下划线或其他空格的文件夹。 (2认同)

Jos*_*van 34

对于在Windows上遇到此问题并且上述方法都不起作用的任何人,请尝试从cmd.exe运行此命令.通过PowerShell执行这些命令导致安装每次都失败.

  • 同样的问题,Powershell 和 CMD 参数处理工作方式不同,并且似乎令人困惑 MVN (2认同)
  • 在 PowerShell 中,“.”运算符很重要,因为它与大多数其他 .NET 语言一样用于对象属性/方法访问。如果参数中有点,通常我过去会引用这些点,以便让 PowerShell 将它们视为文字字符串。 (2认同)

J.J*_*van 20

在Windows上,就我而言,你必须用引号括起所有参数.

因此,如果您想创建maven webapp原型,您可以执行以下操作:

先决条件:

  1. 确保已安装maven并将其放在PATH环境变量中.

如何:

  1. 打开windows powershell
  2. mkdir MyWebApp
  3. cd MyWebApp
  4. mvn archetype:生成"-DgroupId = com.javan.dev"" - DartifactId = MyWebApp"" - DarchetypeArtifactId = maven-archetype-webapp"" - DinteractiveMode = false"

在此输入图像描述

注意:这仅在Windows 10 PowerShell上进行测试


小智 9

完全正确。使用时PowerShell,需要加上引号。
我运行命令并在带点的参数两边加引号,这有效。 您应该
键入,而不是键入。1.4"1.4"

第一次:

mvn archetype:generate 
   -DgroupId=com.mycompany.app 
   -DartifactId=my-app 
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DarchetypeVersion=1.4 -DinteractiveMode=false
Run Code Online (Sandbox Code Playgroud)
Error:
[ERROR] The goal you specified requires a project to execute 
but there is no POM in this directory 
(C:\Users\jcrojas\OneDrive - Superfinanciera\Personal\Aprendizaje\Maven\test). 
Please verify you invoked Maven from the correct directory. -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

第二次:

mvn archetype:generate 
   -DgroupId=**"com.mycompany.app"** 
   -DartifactId=my-app 
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DarchetypeVersion=**"1.4"** 
   -DinteractiveMode=false
Run Code Online (Sandbox Code Playgroud)

...建立成功...

如果使用 Windows 命令行CMD.
在这种情况下,不需要引号。


mad*_*nce 8

为Windows用户添加一个答案.如果这些都解决了问题.

不要在space之前或之后添加=

-DgroupId= com.company.module //Wrong , Watch the space after the equal to 
-DgroupId=com.company.module //Right 
Run Code Online (Sandbox Code Playgroud)

最好将所有内容放在双引号内,例如"-DgroupId = com .."这将给出确切的错误而不是一些随机错误.

奇怪的是,maven甚至不在文档中提到这一点.

  • 你的解决方案有效,我把所有的 -D 部分放在“”中...像 Maven 这样设计糟糕且编码不良的产品居然变得如此受欢迎,真是太神奇了... (3认同)

Mid*_*eel 5

就我而言,这是因为我从浏览器复制粘贴了命令,结果发现破折号不是 ASCII 破折号,只需删除并再次键入破折号即可。

http://www.toptip.ca/2017/04/maven-most-weird-error-causing-failure.html


归档时间:

查看次数:

155719 次

最近记录:

7 年,2 月 前