2015-12-22 91 views
1

我想上傳文件到HDFS。我用下面的罐子作爲依賴編譯我的代碼:No fileSystem for scheme:hdfs and Class org.apache.hadoop.DistributedFileSystem not found

  • Hadoop的AUTH-2.6.1.jar,
  • Hadoop的共2.6.1.jar和
  • Hadoop的HDFS-2.6.1。罐子,

我的代碼:

enter image description here

我用Ant編譯它。但是,它給了我這個錯誤:No FileSystem for scheme:hdfs

然後,我改變了代碼,並再次編譯: enter image description here

但現在我得到了另一個錯誤:Class org.apache.hdfs.DistributedFileSystem not found

怎麼了?我該怎麼做?

回答

1

DistributedFileSystemhadoop-core的一部分。

爲了解決這個問題,你需要包括hadoop-core-1.2.1.jar也(注:我使用Maven建築):

<dependency> 
    <groupId>org.apache.hadoop</groupId> 
    <artifactId>hadoop-core</artifactId> 
    <version>1.2.1</version> 
</dependency> 

總之,我使用以下Maven的依賴關係:

<dependency> 
    <groupId>org.apache.hadoop</groupId> 
    <artifactId>hadoop-common</artifactId> 
    <version>2.7.1</version> 
</dependency> 

<dependency> 
    <groupId>org.apache.hadoop</groupId> 
    <artifactId>hadoop-mapreduce-client-core</artifactId> 
    <version>2.7.1</version> 
</dependency> 

<dependency> 
    <groupId>org.apache.hadoop</groupId> 
    <artifactId>hadoop-core</artifactId> 
    <version>1.2.1</version> 
</dependency> 
+0

謝謝,我通過使用httpFS + webHDFS解決了這個問題。 – Xiyangyang