public static String getYmlNew(String key){
Resource resource = new ClassPathResource(“application-dev.yml”);
Properties properties = null;
try {
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(resource);
properties = yamlFactory.getObject();
} catch (Exception e) {
e.printStackTrace();
return null;
}
return (String) properties.get(key);
}
spring-boot 读取yml配置信息
最新推荐文章于 2024-02-02 17:08:51 发布