我正在关注Maven in 5 Minutes手册,内容如下:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
我收到以下错误:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.160s
[INFO] Finished at: Sat Dec 10 16:27:55 ICT 2011
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (
D:\experiment\maven). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
更多信息:
PS D:\experiment\maven> ping http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.2/maven-archetype-plugin-2.2.pom
Ping request could not find host http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.2/maven-archetype-plugin-2.2.pom. Please check the name and try again.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.869s
[INFO] Finished at: Sat Dec 10 19:03:37 ICT 2011
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (
D:\experiment\maven). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to exe
cute but there is no POM in this directory (D:\experiment\maven). Please verify you invoked Maven fr
om the correct directory.
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:89)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
答案 0 :(得分:22)
我正在使用Windows 7 SP1。
我遇到了问题,因为我使用PowerShell运行它。
使用CMD.EXE运行它时工作正常。
感谢大家的帮助。
答案 1 :(得分:9)
我遇到了同样的问题,看起来我们有类似的设置
这是我必须做的事情:
将所有"-D..."
换成双引号,例如
mvn archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DgroupId=com.mycompany.app" "-DartifactId=my-app"
确保在环境变量中正确设置"HTTP_PROXY"
(通过键入"echo $Env:HTTP_PROXY"
)
答案 2 :(得分:2)
首先,您应该遵循错误消息的建议。使用其他标志调用Maven以获取更多信息。
其次,您应确保您的互联网连接在命令行中正常运行。您是否可以从浏览器下载http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.2/maven-archetype-plugin-2.2.pom
?如果没有,Maven无法下载必要的插件,因此在构建项目之前必须进行正常的自举。检查您的浏览器是否使用代理,并且您没有定义环境变量HTTP_PROXY
。如果是这种情况,请在shell中定义您使用变量HTTP_PROXY
的命令:
set HTTP_PROXY=http://<my.proxy.host>:<port>
使用my.proxy.host
和port
的正确值。如果这样可行,那么为系统定义环境变量,以便每个打开的shell都定义了该环境变量。
请将这些信息添加到您的问题中,并抱歉提出错误的建议ping http://....
,这是无效的。
答案 3 :(得分:2)
我遇到了类似的错误,尝试使用双引号来包装所有-D
,这对我有用..
示例:
mvn archetype:create "-DarchetypeGroupId=org.springframework.ws" "-DarchetypeArtifactId=spring-ws-archetype" "-DarchetypeVersion=2.1.4.RELEASE" "-DgroupId=com.mycompany.hr" "-DartifactId=holidayService"
答案 4 :(得分:0)
我不确定您是否正在从POM目录运行“mvn compile”,这就是它要求POM的原因。
如果是这样,只需转到pom所在的目录,然后激活“mvn install”或任何其他Maven命令。
答案 5 :(得分:0)
我花了75分钟在批处理模式下使用PowerShell在Windows 10上创建Maven快速入门项目。显然我犯了三个不同的错误。
执行以下操作:
-B
用于批处理模式,或-DinteractiveMode=false
代替-DarchetypeGroupId=org.apache.maven.archetypes
-DarchetypeArtifactId=maven-archetype-quickstart
-DarchetypeVersion=1.1
-DgroupId=com.example
-DartifactId=app
-Dversion=1.0-SNAPSHOT
-Dpackage=com.example.project
"-DgroupId=com.example"
完整示例:
archetype:generate