zoukankan      html  css  js  c++  java
  • 使用Spring-boot小结

    Spring-boot的特点是,通过注入的方式生成FsShell对象,来操作HDFS,其底层封装了HDFS的的shell命令

    1. 添加Spring-boot依赖

    pom.xml文件

     <!--添加spring-boot依赖-->
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-hadoop-boot</artifactId>
                <version>2.5.0.RELEASE</version>
            </dependency>
    

    2.上代码

    //添加注解,表名是SpringBoot应用
    @SpringBootApplication
    public class SpringBootApp implements CommandLineRunner {
    
        //通过注入方式得到FsShell
        @Autowired
        FsShell mFsShell;
    
    
        public void run(String... strings) throws Exception {
            Collection<FileStatus> fileStatuses = mFsShell.lsr("/");
            for (FileStatus fileStatus : fileStatuses) {
                System.out.println(">  " + fileStatus.getPath());
            }
        }
    
        public static void main(String[] agrs) {
            //通过SpringApplication来执行run方法
            SpringApplication.run(SpringBootApp.class, agrs);
        }
    }
    
  • 相关阅读:
    mybatis动态sql和分页
    mybatis入门
    IDEA
    Linux环境搭建
    svn
    jwt
    Vuex
    SPA项目开发之CRUD+表单验证
    JavaScript可视化框架——Echarts
    python+selenium六:隐式等待
  • 原文地址:https://www.cnblogs.com/flowyourheart/p/shi-yongSpringboot-xiao-jie.html
Copyright © 2011-2022 走看看