package com.utils;
import java.io.InputStream;
import java.util.Properties;
/**
* 文件数值获取
*/
public class PropertyValues {
public static Properties properties;
static {
loadPropertyValue();
}
public static void loadPropertyValue(){
InputStream inputStream=null;
inputStream= PropertyValues.class.getClassLoader().getResourceAsStream("wsData.properties");
properties=new Properties();
try {
properties.load(inputStream);
}catch (Exception e){
System.out.println("get value failed!");
}finally {
try {
inputStream.close();
}catch (Exception e){
System.out.println("IO close exception!");
}
}
}
public static String getPropertyValue(String key){
if (properties==null){
loadPropertyValue();
}
return properties.getProperty(key);
}
}
Springboot获取XXX.properties文件的值
猜你喜欢
转载自blog.csdn.net/weixin_39102174/article/details/90616943
今日推荐
周排行