1. 在Java语言中,使用类似config.properties这样的文本文件作为资源文件
2. 在后端代码 类中获取config.properties中的内容:(下面的类是单例模式)
private static String Type;
static {
res = ResourceBundle.getBundle("conf/config"); //获取config.properties文件
MSECOND = Integer.valueOf(resource.getString("MAX_SECOND")); //获取config.properties文件中的MAX_SECOND的值
}
3. 或者如下:
static {
Properties props = null;
try {
props = PropertiesLoaderUtils.loadAllProperties("conf/rpc.properties");
BASE_URL = props.get("BaseInfo").toString();
SERVICE_NEW_URL = props.get("Service").toString();
} catch (IOException e) {
e.printStackTrace();
}
}