属性配置类来自:https://commons.apache.org/
这些是我正在使用的库:
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
代码:
PropertiesConfiguration configWatchdog;
try {
configWatchdog = new PropertiesConfiguration(configName);
// FileChangedReloadingStrategy reload = new FileChangedReloadingStrategy();
configWatchdog.setReloadingStrategy(new FileChangedReloadingStrategy());
// String a= configWatchdog.getString("controller.tresholdValue");
componentConfiguration = (Map<String, Object>) configWatchdog;
// componentConfiguration.put("controller.tresholdValue",
// configWatchdog.getString("controller.tresholdValue"));
} catch (ConfigurationException exception) {
// TODO Auto-generated catch block
exception.printStackTrace();
}
我喜欢在运行时观察配置更改并使用更改来检查值。有人知道如何获得价值观?