除了注解等方式(参考: Spring Boot获取yml文件配置注入Map/List/String等类型 ),还有一种直接读取的实现:
public static Object readProperties(String key) {
Object propertyValue = null;
Resource resource = new ClassPathResource("config/application-custom.yml");
Properties properties;
try {
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(resource);
properties = yamlFactory.getObject();
propertyValue = properties.get(key);
} catch (Exception e) {
e.printStackTrace();
}
return propertyValue;
}
最新评论
什么时候出新版啊已经过了半个月了
有没有港台节目直播?
One Drive提取密码?
大佬请问每次都需要在plugins中启动tiktok吗,还是直接启动app