java 读取 yml 配置文件

1年前 ⋅ 1076 阅读
        // 读取 application-dev.yml
        Yaml yaml = new Yaml();
        Map dev = yaml.load(new FileInputStream(System.getProperty("user.dir") + "/src/main/resources/application-dev.yml"));
        Map spring = (Map)dev.get("spring");
        Map datasource = (Map)spring.get("datasource");
        String url = (String)datasource.get("url");
        String username = (String)datasource.get("username");
        String password = datasource.get("password") + "";

全部评论: 0

    我有话说: