spring hadoop

一、源码
// 如下代码实现 读取指定hdfs路径下tmp文件夹下面所有的文件(包括子文件)
@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
        // 构建FsShell对象
@Autowired
private FsShell shell; 
        // 实现run方法
@Override
public void run(String... args) {
for (FileStatus s : shell.lsr("/tmp")) {
System.out.println("> " + s.getPath());
}
}

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
二、配置文件
// 指定对应的hdfs的url(hadoop filesystem uri)
spring:
  main:
    show_banner: false // 输出头部信息(作用不大 可以修改成true 看看)
  hadoop:
    fsUri: hdfs://10.33.96.241:8020

猜你喜欢

转载自dalan-123.iteye.com/blog/2258751