Maven在5分钟内发行

pio*_*ion 11 powershell maven

在5分钟手册中关注Maven,内容如下:

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

我收到以下错误:

[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
Run Code Online (Sandbox Code Playgroud)

更多信息:

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
Run Code Online (Sandbox Code Playgroud)

pio*_*ion 22

我使用的是Windows 7 SP1.

我遇到了这个问题因为我使用PowerShell运行它.

当我使用CMD.EXE运行它时它工作正常.

谢谢大家的帮助.


dsu*_*sun 9

我遇到了同样的问题,看起来我们有类似的设置

  • Windows 7的
  • 电源外壳
  • HTTP代理

这是我要做的事情:

  1. 包裹所有"-D..."内部双引号,例如

    mvn archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DgroupId=com.mycompany.app" "-DartifactId=my-app"
    
    Run Code Online (Sandbox Code Playgroud)
  2. 确保"HTTP_PROXY"在环境变量中正确设置(通过键入来检查"echo $Env:HTTP_PROXY")


mli*_*elt 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>
Run Code Online (Sandbox Code Playgroud)

具有正确的my.proxy.host和值port。如果效果很好,请为系统定义环境变量,以便每个打开的 shell 都定义了该环境变量。

请将这些信息添加到您的问题中,对于致电 的错误建议表示抱歉ping http://....,该建议不起作用。