您的位置:首页 > 运维架构 > Apache

apache commons configuration自动加载修改的配置文件不用重启服务器

2012-12-04 15:09 633 查看
1. 引入jar包commons-configuration-1.6.jar;

2.  String file_name = (new Global()).getClass().getClassLoader().getResource("config/config.properties").getFile();

      file_name = file_name.replace("%20", " ");

      propconfig = new PropertiesConfiguration(file_name);

     //设置编码

     propconfig.setEncoding("UTF-8");

     //设置自动冲加载机制

     propconfig.setReloadingStrategy(new FileChangedReloadingStrategy());

    String mapRefresh = propconfig.getProperty("map.refreshTime").toString().trim();

    即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐