【问题标题】:Loading updated properties automatically from multiple properties files从多个属性文件自动加载更新的属性
【发布时间】:2012-07-31 19:21:29
【问题描述】:

我的要求是在对属性文件进行更改时自动更新我的应用程序的配置。
为了维护属性,我使用 Apache Commons Configuration 项目中的 PropertiesConfiguration。(使用 commons-configuration-1.6.jar)。
使用 FileChangedReloadingStrategy 非常适合对单个属性文件进行的更改,并被我的应用程序拾取。

    PropertiesConfiguration config = new PropertiesConfiguration();
    config.load(new File("../test1.properties"));
    config.load(new File("../test2.properties"));
    config.setReloadingStrategy(new FileChangedReloadingStrategy());

但是我正在使用多个属性文件并使用它们的加载方法,当更新任何一个属性文件时,我需要能够检测到更改并自动更新我的项目中的配置。
有没有办法使用 FileChangedReloadingStrategy 进行此更新?
或者您有什么其他方法可以建议我使用吗?

【问题讨论】:

    标签: java apache-commons-config


    【解决方案1】:

    您可以使用CompositeConfiguration 加入两个独立的FileConfigurations,每个FileChangedReloadingStrategy 都有自己的FileChangedReloadingStrategy

    【讨论】:

      猜你喜欢
      • 2012-04-28
      • 1970-01-01
      • 2012-05-07
      • 2015-12-15
      • 2016-06-18
      • 1970-01-01
      • 2019-03-30
      • 2012-11-28
      • 2012-07-08
      相关资源
      最近更新 更多