-
Notifications
You must be signed in to change notification settings - Fork 311
spring boot integration
王宇轩 edited this page Sep 26, 2018
·
2 revisions
config-toolkit:
connect-str: 192.168.5.99:2181
root-node: /projectx/modulex
version: 1.0.0
@Configuration
public class ConfigToolkitConfig {
@Bean
public ZookeeperConfigProfile getConfigProfile(@Value("${config-toolkit.connect-str}") String connectStr,
@Value("${config-toolkit.root-node}") String rootNode,
@Value("${config-toolkit.version}") String version) {
return new ZookeeperConfigProfile(connectStr, rootNode, version);
}
@Bean
public ConfigGroup getConfigGroup(ZookeeperConfigProfile configProfile) {
return new ZookeeperConfigGroup(configProfile, "property-group1");
}
}
@Configuration
public class Config {
@Bean
public PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
configurer.setOrder(1);
configurer.setIgnoreUnresolvablePlaceholders(true);
ZookeeperConfigProfile profile = new ZookeeperConfigProfile("localhost:2181", "/projectx/modulex", "1.0.0");
ConfigGroup configGroup1 = new ZookeeperConfigGroup(profile, "property-group1");
ConfigGroup configGroup2 = new ZookeeperConfigGroup(profile, "property-group2");
MutablePropertySources sources = new MutablePropertySources();
sources.addLast(new ConfigGroupResource(configGroup1));
sources.addLast(new ConfigGroupResource(configGroup2));
configurer.setPropertySources(sources);
return configurer;
}
}
https://github.com/crnlmchina/config-toolkit-with-spring-boot