import java.io.InputStream;
import java.util.Properties;
public class PropertiesUtil {
public static Properties getConfig() {
Properties property = new Properties();
try {
ClassLoader classLoader = PropertiesUtil.class.getClassLoader();
InputStream in = classLoader.getResourceAsStream("application.properties");
property.load(in);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return property;
}
public static String getPropertyParam(String key) {
Properties property = new Properties();
try {
ClassLoader classLoader = PropertiesUtil.class.getClassLoader();
InputStream in = classLoader.getResourceAsStream("application.properties");
property.load(in);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return property.getProperty(key);
}
// public static void main(String[] args) {
// System.out.println(PropertiesUtil.getPropertyParam("storeDir"));
// }
}
读取maven中resource下的配置文件工具类
最新推荐文章于 2019-07-15 15:28:04 发布