mvn 命令返回:[ERROR] 您指定的目标需要一个项目来执行,但该目录中没有 POM

nep*_*tom 6 bash maven maven-archetype

按照5 分钟 Mavenarchetype:generate中描述的相同方式创建项目。\n出现此错误:

\n\n
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/mnt/c/Users/etomort/quartz-poc). Please verify you invoked Maven from the correct directory. -> [Help 1]\norg.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/mnt/c/Users/etomort/quartz-poc). Please verify you invoked Maven from the correct directory.\n
Run Code Online (Sandbox Code Playgroud)\n\n

因为这是这么基本的事情,所以我很困惑......

\n\n

我检查了这两个问题:

\n\n\n\n

但接受的答案都没有解决问题。
\n所以,我创建这个问题是为了防止有人碰到它但一开始没有明白。

\n\n

顺便说一句,输入的Maven命令是:

\n\n
mvn archetype:generate -DgroupId=com.mycompany -DartifactId=quartz-poc -DarchetypeArtifactId= maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false  \n
Run Code Online (Sandbox Code Playgroud)\n

Nas*_*hil 13

如果您在Windows上并使用cmd命令行 或PowerShell,则需要将参数括在引号中:

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

在某些机器上,它可以在没有引号的情况下工作cmd


nep*_*tom 3

注意命令中的空格mvn

前后的任何空格=都会导致mvn失败:
在此输入图像描述

在我的问题中,额外的空间位于archetypeArtifactId.
不管它在哪里,Maven 都会抱怨同样的消息。

我无意中引入了具有bash自动完成功能的空格:

在此输入图像描述