public static void main(String[] args) { String result=getProjectConfig("max-file-size"); System.out.println(result); } public static String getProjectConfig(String key) { Properties pros = new Properties(); String value = ""; try { pros.load(new InputStreamReader(PropertiesUtil.class.getResourceAsStream("/application.yml"), "UTF-8")); value = pros.getProperty(key); } catch (Exception e) { return e.getMessage(); } return value; }
本文展示了一种从YAML配置文件中读取特定键值的方法,并通过Java代码示例说明了如何使用Properties类加载和解析application.yml文件中的max-file-size配置。

1148

被折叠的 条评论
为什么被折叠?



