[英]Typo in word “hdfs” gives me: “java.io.IOException: No FileSystem for scheme: hdfs”. Using FileSystem lib over hadoop 2.7.7
While using FileSystem.get(URI.create("hdfs://localhost:9000/"), configuration)
I'm getting the error "Typo in word hdfs", when I tried to run the code gives me the IOException: 在使用FileSystem.get(URI.create("hdfs://localhost:9000/"), configuration)
时,当我尝试运行代码时,出现错误“输入hdfs中的错字”,给我IOException:
java.io.IOException: No FileSystem for scheme: hdfs
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2658)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2665)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:93)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2701)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2683)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:372)
at com.oracle.hadoop.client.Test.main(Test.java:53)
I already tried to use in different ways to use the call to hdfs, I'm using the libraries for hadoop 2.7.7 我已经尝试过以不同的方式使用对hdfs的调用,我正在使用hadoop 2.7.7的库。
Here is my current code: 这是我当前的代码:
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.log4j.BasicConfigurator;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
public class Test {
public static void main(String []args) {
Configuration conf = new Configuration();
InputStream in = null;
try {
FileSystem fs = FileSystem.get(URI.create("hdfs://localhost:9000/"), conf);
in = fs.open(new Path(uri));
IOUtils.copyBytes(in, System.out, 4096, false);
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeStream(in);
}
}
实际上,我只是添加了这个Maven依赖项: http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-hdfs/2.7.7
: http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-hdfs/2.7.7
到maven pom.xml
并已解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.