1

我的要求是在对属性文件进行更改时自动更新我的应用程序的配置。
为了维护属性,我使用了 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 进行此更新?
或者你有什么其他方法可以建议我使用吗?

4

1 回答 1

2

您可以使用 aCompositeConfiguration连接两个单独FileConfiguration的 s,每个 s 都有自己的FileChangedReloadingStrategy

于 2012-07-31T19:25:38.977 回答