我有以下程序,我正在使用maven构建,我在程序下面给出了POM文件。在构建时,我收到pom文件下面的错误。我也是hadoop和maven的新手。我不知道我是否正在使用正确的工件(hadoop-common)构建程序。该程序适用于hadoop-2.2.0。请详细说明一下。
package com.example.hdfs;
//cc URLCat Displays files from a Hadoop filesystem on standard output using a URLStreamHandler
import java.io.InputStream;
import java.net.URL;
import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;
//vv URLCat
public class URLCat {
static {
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
}
public static void main(String[] args) throws Exception {
InputStream in = null;
try {
in = new URL(args[0]).openStream();
IOUtils.copyBytes(in, System.out, 4096, false);
} finally {
IOUtils.closeStream(in);
}
}
}
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hdfsTrying</groupId>
<artifactId>hdfstrying</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hdfstrying</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>hdfsTrying.hdfstrying.URLCat</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Downloading: http://repo1.maven.org/maven2/org/apache/commons/commons-math/2.1/commons-math-2.1.jar
Downloading: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar
Downloading: http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar
Downloading: http://repo1.maven.org/maven2/org/apache/avro/avro/1.7.4/avro-1.7.4.jar
Downloading: http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
Downloading: http://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
Downloading: http://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/3.4.5/zookeeper-3.4.5.jar
Downloading: http://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar
Downloaded: http://repo1.maven.org/maven2/org/apache/avro/avro/1.7.4/avro-1.7.4.jar (297 KB at 1.7 KB/sec)
[WARNING] Checksum validation failed, could not read expected checksum: java.net.ConnectException: null to http://repo1.maven.org/maven2/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar.sha1 for http://repo1.maven.org/maven2/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar
[WARNING] Checksum validation failed, could not read expected checksum: java.net.ConnectException: null to http://repo1.maven.org/maven2/org/apache/avro/avro/1.7.4/avro-1.7.4.jar.sha1 for http://repo1.maven.org/maven2/org/apache/avro/avro/1.7.4/avro-1.7.4.jar
[WARNING] Checksum validation failed, could not read expected checksum: java.net.ConnectException: null to http://repo1.maven.org/maven2/org/apache/commons/commons-math/2.1/commons-math-2.1.jar.sha1 for http://repo1.maven.org/maven2/org/apache/commons/commons-math/2.1/commons-math-2.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4:56.462s
[INFO] Finished at: Sat Nov 30 10:39:37 IST 2013
[INFO] Final Memory: 9M/97M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hdfstrying: Could not resolve dependencies for project hdfsTrying:hdfstrying:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.thoughtworks.paranamer:paranamer:jar:2.3, com.google.protobuf:protobuf-java:jar:2.5.0, org.apache.zookeeper:zookeeper:jar:3.4.5, org.apache.commons:commons-compress:jar:1.4.1: Could not transfer artifact com.thoughtworks.paranamer:paranamer:jar:2.3 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar: UnresolvedAddressException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project hdfstrying: Could not resolve dependencies for project hdfsTrying:hdfstrying:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.thoughtworks.paranamer:paranamer:jar:2.3, com.google.protobuf:protobuf-java:jar:2.5.0, org.apache.zookeeper:zookeeper:jar:3.4.5, org.apache.commons:commons-compress:jar:1.4.1: Could not transfer artifact com.thoughtworks.paranamer:paranamer:jar:2.3 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:190)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:104)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
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.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
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:534)
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:616)
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)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project hdfsTrying:hdfstrying:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.thoughtworks.paranamer:paranamer:jar:2.3, com.google.protobuf:protobuf-java:jar:2.5.0, org.apache.zookeeper:zookeeper:jar:3.4.5, org.apache.commons:commons-compress:jar:1.4.1: Could not transfer artifact com.thoughtworks.paranamer:paranamer:jar:2.3 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:156)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:165)
... 22 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: com.thoughtworks.paranamer:paranamer:jar:2.3, com.google.protobuf:protobuf-java:jar:2.5.0, org.apache.zookeeper:zookeeper:jar:3.4.5, org.apache.commons:commons-compress:jar:1.4.1: Could not transfer artifact com.thoughtworks.paranamer:paranamer:jar:2.3 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:541)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:220)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifacts(DefaultRepositorySystem.java:331)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:434)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:150)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact com.thoughtworks.paranamer:paranamer:jar:2.3 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$3.wrap(AsyncRepositoryConnector.java:1426)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$3.wrap(AsyncRepositoryConnector.java:1417)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask.flush(AsyncRepositoryConnector.java:908)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask.flush(AsyncRepositoryConnector.java:902)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector.get(AsyncRepositoryConnector.java:279)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:460)
... 27 more
Caused by: java.net.ConnectException: null to http://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:83)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:857)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:731)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:484)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask$1.onThrowable(AsyncRepositoryConnector.java:532)
at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:287)
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:87)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:857)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:731)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:484)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask$1.onThrowable(AsyncRepositoryConnector.java:532)
at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:287)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.abort(NettyAsyncHttpProvider.java:1301)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:853)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:731)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:484)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask$1.onThrowable(AsyncRepositoryConnector.java:532)
at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:287)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.abort(NettyAsyncHttpProvider.java:1301)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:853)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:731)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:484)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask.run(AsyncRepositoryConnector.java:771)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector.get(AsyncRepositoryConnector.java:270)
... 28 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:89)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:510)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:140)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:103)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:60)
at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:82)
at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:114)
at org.jboss.netty.channel.Channels.connect(Channels.java:541)
at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:218)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:227)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:188)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:836)
... 50 more
[ERROR]
[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 articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
答案 0 :(得分:0)
你有代理吗?如果是,请在settings.xml
目录的apache-maven-3.*.*/conf
文件中添加代理详细信息。在settings.xml
文件中它将是这样的。取消注释并添加您的代理详细信息。
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>