1.apollo包的版本(2.0.0)
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-core</artifactId>
<version>2.0.0</version>
</dependency>
2.apollo配置的优先级源码解析
主要是两个文件:com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer和com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor
(1)ApolloApplicationContextInitializer.class
会将apollo配置放到environment的first,如下代码environment.getPropertySources().addFirst(composite):
@Override
public void initialize(ConfigurableApplicationContext context) {
ConfigurableEnvironment environment = context.getEnvironment();
if (!environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, Boolean.class, false)) {
logger.debug("Apollo bootstrap config is not enabled for context {}, see property: ${
{}}", context, PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED);
return;
}
logger.debug("Apollo bootstrap config is enabled for context {}", context);
initialize(environment);
}
/**
* Initialize Apollo Configurations Just after