读取项目配置文件工具类
public class ConfigReaderUtil {
public ConfigReaderUtil(){}
private static Properties props = new Properties();
static{
try {
//加载配置文件,需要手动指定配置文件
props.load(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties"),"UTF-8"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/*根据key获取value*/
public static String getValue(String key){
return props.getProperty(key).trim();
}
}