标签:
先创建*.properties文件
#openapi地址配置
openapiDir = openapi
在接口类中定义
public static String OPEN_API = "openapi";
static {
InputStream is = null;
try {
Properties pro = new Properties();
is = CommomUtil.class.getResourceAsStream("/*.properties");
pro.load(is);
OPEN_API = pro.getProperty("openapiDir");
APPKEY = pro.getProperty("APPKEY");
LOGINKEY = pro.getProperty("LOGINKEY");
is.close();
} catch (IOException e) {
e.printStackTrace();
if (is != null) {
try {
is.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
就能获取配置文件的值
标签:
原文地址:http://www.cnblogs.com/yinglgn/p/5126818.html