springBoot reads properites file

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);
}

}

Guess you like

Origin blog.csdn.net/dndndnnffj/article/details/110199282