maven 3.0.5的“读取原型目录时出错”

时间:2013-10-02 11:08:18

标签: maven maven-3

我在Windows 7中遇到maven 3.0.5的问题: 我做的时候 mvn archetype:generate -DgroupId=p1 -DartifactId=pn -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

在命令行中

这是maven中的基本命令。 我有这个错误:

[INFO] ------------------------------------------------------------------------
[INFO] Building carbon Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ carbon >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ carbon <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ carbon ---
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.TransferFailedException: repo1.maven.org
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:892)
        at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:11
6)
        at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
        at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.do
wnloadCatalog(RemoteCatalogArchetypeDataSource.java:119)
        at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.ge
tArchetypeCatalog(RemoteCatalogArchetypeDataSource.java:87)
        at org.apache.maven.archetype.DefaultArchetypeManager.getRemoteCatalog(D
efaultArchetypeManager.java:216)
        at org.apache.maven.archetype.DefaultArchetypeManager.getRemoteCatalog(D
efaultArchetypeManager.java:205)
        at org.apache.maven.archetype.ui.generation.DefaultArchetypeSelector.get
ArchetypesByCatalog(DefaultArchetypeSelector.java:200)
        at org.apache.maven.archetype.ui.generation.DefaultArchetypeSelector.sel
ectArchetype(DefaultArchetypeSelector.java:71)
        at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execu
te(CreateProjectFromArchetypeMojo.java:197)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        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(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: java.net.UnknownHostException: repo1.maven.org
        at java.net.InetAddress.getAllByName0(InetAddress.java:1243)
        at java.net.InetAddress.getAllByName(InetAddress.java:1155)
        at java.net.InetAddress.getAllByName(InetAddress.java:1091)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.SystemDefa
ultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultCli
entConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultCli
entConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.ManagedCli
entConnectionImpl.open(ManagedClientConnectionImpl.java:294)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.tryConnect(DefaultRequestDirector.java:645)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.execute(DefaultRequestDirector.java:480)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:906)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:805)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(A
bstractHttpClientWagon.java:746)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:886)
        ... 31 more
[WARNING] No archetype found in remote catalog. Defaulting to internal catalog
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
 maven-archetype-webapp:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: p1
[INFO] Parameter: packageName, Value: p1
[INFO] Parameter: package, Value: p1
[INFO] Parameter: artifactId, Value: pn
[INFO] Parameter: basedir, Value: C:\Java\workspaces\carbon
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.929s
[INFO] Finished at: Wed Oct 02 13:07:05 WAT 2013
[INFO] Final Memory: 10M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.2:generate (default-cli) on project carbon: Unable to add module to the current
 project as it is not of packaging type 'pom' -> [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

1 个答案:

答案 0 :(得分:2)

看起来无法从运行该命令的计算机上找到主机名“repo1.maven.org”。

检查您是否可以ping主机“repo1.maven.org”并从浏览器访问http://repo1.maven.org