java 请验证您从正确的目录中调用了 Maven

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30191612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 16:37:56  来源:igfitidea点击:

Please verify you invoked Maven from the correct directory

javamavenjersey

提问by MrPencil

I have installed maven :

我已经安装了 maven :

C:\Windows\System32>mvn --version
Apache Maven 3.3.3 (7994120775791599e405a7528ec3e0dke21dja06; 2015-04-22T13:57:3
7+02:00)
Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.3.3
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_51\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"

I am trying to generate Jersey glassfish project with the aid of maven prompt but when I type the following:

我正在尝试借助 Maven 提示生成 Jersey glassfish 项目,但是当我键入以下内容时:

D:\maven>mvn archetype:generate  -DarchetypeGroupId=org.glassfish.jersey.archety
pes -DinteractiveMode=false \ -DarchetypeVersion=2.17

I am getting this error:

我收到此错误:

The goal you specified requires a project to execute but there is no POM in this directory (D:\maven). Please verify you invoked Maven from the correct directory. -> [Help 1]

您指定的目标需要一个项目来执行,但在此目录 (D:\maven) 中没有 POM。请验证您从正确的目录调用了 Maven。-> [帮助 1]

I dont understand the error: Which project is required here since I am trying to generate one? And how should I create the pom.xml file? I thought it is created by the project generation.

我不明白错误:因为我试图生成一个项目,所以这里需要哪个项目?我应该如何创建 pom.xml 文件?我以为它是由项目生成创建的。

I appreciate any help.

我很感激任何帮助。

Editwhen I type it without \

当我没有输入时进行编辑\

D:\maven>mvn archetype:generate  -DarchetypeGroupId=org.glassfish.jersey.archety
pes  -DinteractiveMode=false -DarchetypeVersion=2.17
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) > generate-sources
@ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) < generate-sources
@ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.glassfish.jer
sey.archetypes:maven-archetype-quickstart:2.17)
Downloading: https://repo.maven.apache.org/maven2/org/glassfish/jersey/archetype
s/maven-archetype-quickstart/2.17/maven-archetype-quickstart-2.17.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.542 s
[INFO] Finished at: 2015-05-12T16:39:51+02:00
[INFO] Final Memory: 17M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.3:generate (default-cli) on project standalone-pom: The desired archetype does
not exist (org.glassfish.jersey.archetypes:maven-archetype-quickstart:2.17) -> [
Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

D:\maven>

采纳答案by RPresle

I'll go for an answer now.

我现在去找答案。

So the first part of your problem was the caracter "\". See this thread

所以你的问题的第一部分是字符“\”。看到这个线程

Then for your second problem : it is said The desired archetype does not exist. This archetype maven-archetype-quickstart doesn't exist in maven repository. Please refer to this linkto choose the archetype you are looking for and put it in your command.

那么对于你的第二个问题:据说 The desired archetype does not exist。这个原型 maven-archetype-quickstart 在 maven 存储库中不存在。请参阅此链接以选择您正在寻找的原型并将其放入您的命令中。

At the end you command must have at least 2 argument -DarchetypeGroupIdand -DarchetypeArtifactId. For example :

最后,您的命令必须至少有 2 个参数-DarchetypeGroupId-DarchetypeArtifactId. 例如 :

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp