private static Properties props = new Properties();
// 静态块
static {
ClassPathResource cpr = new ClassPathResource("conf/main-setting.properties");//自动加载properties文件
try {
props.load(cpr.getInputStream());
} catch (IOException exception) {
// 异常处理
}
}
// 通过键获取值
public static String getProperty(String key){
return props.getProperty(key);
}