- /**
- * 读取配置文件
- * @param file
- * @return
- */
- public static PropertiesConfiguration loadConfig(String file){
- PropertiesConfiguration config = null;
- try {
- config = new PropertiesConfiguration(file);
- config.setEncoding("UTF-8");
- config.setReloadingStrategy(new FileChangedReloadingStrategy());
- config.setAutoSave(true);
- logger.info("加载配置文件成功...");
- } catch (ConfigurationException e) {
- logger.info("加载配置文件失败,异常信息:"+e.getLocalizedMessage());
- }
- return config;
- }
- public static Configuration config = loadConfig("config.properties");
- ConfigUtils.config.getString("weixin.app_id")
来源: http://www.phpxs.com/code/1001902/