@Bean
public DynamicConfiguration addArchaiusConfiguration() {
// 文件
PolledConfigurationSource source = new URLConfigurationSource("classpath:other/extra.properties");
// 数据库
//PolledConfigurationSource source = new JDBCConfigurationSource(dataSource, "select prop_key, prop_value from properties", "prop_key", "prop_value");
return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
//return new DynamicConfiguration(source, new FixedDelayPollingScheduler(30000, 60000, false));
}
或
// ConfigurationManager
ConfigurationManager.install(new DynamicConfiguration(source, new FixedDelayPollingScheduler()));
// DynamicPropertyFactory
DynamicPropertyFactory.initWithConfigurationSource(new DynamicConfiguration(source, new FixedDelayPollingScheduler()));
POM
获取动态属性
监听属性变化
默认动态配置文件
添加动态配置文件(越靠后的优先级越高)
动态加载任务
添加动态配置数据源(仅限一个) 优先级大于
archaius.configurationSource.additionalUrls
或
启用JMX
或