Hadoop3.1.1 报Exception in thread “main” org.apache.hadoop.fs.UnsupportedFileSystemException: No FileSystem for scheme "hdfs"解决

配置环境:

CentOS 7 64位

eclipse-jee-2019-06-R-linux-gtk-x86_64.tar

hadoop-3.1.1

jdk-8u211-linux-x64.tar

	Configuration conf = new Configuration();
	
	FileSystem fs = FileSystem.get(conf);
	
	Path src = new Path("hdfs://namenode:9000/jdk-7u80-linux-x64.tar.gz");
	
	FSDataInputStream in = fs.open(src);
	
	FileOutputStream os = new FileOutputStream("/home/hlmou/download");
	
	IOUtils.copy(in, os);

导入jar包:

share/hadoop/hdfs/hadoop-hdfs-3.1.1.jar

share/hadoop/hdfs/lib/*

share/hadoop/common/hadoop-common-3.1.1.jar

share/hadoop/common/lib/*

报错:

Exception in thread "main" org.apache.hadoop.fs.UnsupportedFileSystemException: No FileSystem for scheme "hdfs"
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:3332)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3352)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:124)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:3403)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3371)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:477)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:226)
at edu.study.hdfs.HdfsUtil.main(HdfsUtil.java:18)

问题:jar依赖出错

解决:导入依赖jar包

share/hadoop/hdfs/hadoop-hdfs-3.1.1-tests.jar

share/hadoop/hdfs/hadoop-hdfs-client-3.1.1.jar

share/hadoop/hdfs/hadoop-hdfs-client-3.1.1-tests.jar

share/hadoop/hdfs/hadoop-hdfs-httpfs-3.1.1.jar

share/hadoop/hdfs/hadoop-hdfs-native-client-3.1.1.jar

share/hadoop/hdfs/hadoop-hdfs-native-client-3.1.1-tests.jar

share/hadoop/hdfs/hadoop-hdfs-nfs-3.1.1.jar

share/hadoop/hdfs/hadoop-hdfs-rbf-3.1.1.jar

share/hadoop/hdfs/hadoop-hdfs-rbf-3.1.1-tests.jar