springBoot 读取 properites文件

public class PropertiesUtils {

private static  Properties props;
/**获取 application.properties内的文件值 */

static{
    Resource resource = new ClassPathResource("application.properties");
    try {
        props = PropertiesLoaderUtils.loadProperties(resource);
    } catch (IOException e) {
        e.printStackTrace();
    }
}


public static String getProperties(String key) {
    return props.getProperty(key);
}

}

posted @ 2020-11-26 18:09  gudian  阅读(15)  评论(0)    收藏  举报