Closed yinhaox closed 1 month ago
我想使用org.apache.commons.configuration2作为动态配置源
为此我写了个简单的demo:
public class MyDynamicPropertiesSource implements DynamicPropertiesSource { @Override public MapPropertySource create(Environment environment) { Parameters params = new Parameters(); File propertiesFile = new File("config.properties"); ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration> builder = new ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class) .configure(params.fileBased().setFile(propertiesFile)); PeriodicReloadingTrigger trigger = new PeriodicReloadingTrigger(builder.getReloadingController(), null, 15, TimeUnit.SECONDS); trigger.start(); try { return new ConfigurationPropertySource("local", builder.getConfiguration()); } catch (ConfigurationException e) { throw new RuntimeException(e); } } @Override public int getOrder() { return 0; } }
ConfigurationPropertySource是configuration2提供的Spring PropertySources
但是DynamicPropertiesSource接口只支持返回MapPropertySource。
是否可以修改DynamicPropertiesSource接口里返回值的定义为PropertySource<?>
我想使用org.apache.commons.configuration2作为动态配置源
为此我写了个简单的demo:
ConfigurationPropertySource是configuration2提供的Spring PropertySources
但是DynamicPropertiesSource接口只支持返回MapPropertySource。
是否可以修改DynamicPropertiesSource接口里返回值的定义为PropertySource<?>