|
@@ -611,6 +611,17 @@ ConfigFile configFile = ConfigService.getConfigFile("test", ConfigFileFormat.XML
|
|
|
String content = configFile.getContent();
|
|
|
```
|
|
|
|
|
|
+### 3.1.5 Read the configuration corresponding to multiple appid and their namespaces.(added in version 2.4.0)
|
|
|
+Specify the corresponding appid and namespace to retrieve the config, and then obtain the properties.
|
|
|
+```java
|
|
|
+String someAppId = "Animal";
|
|
|
+String somePublicNamespace = "CAT";
|
|
|
+Config config = ConfigService.getConfig(someAppId, somePublicNamespace);
|
|
|
+String someKey = "someKeyFromPublicNamespace";
|
|
|
+String someDefaultValue = "someDefaultValueForTheKey";
|
|
|
+String value = config.getProperty(someKey, someDefaultValue);
|
|
|
+```
|
|
|
+
|
|
|
## 3.2 Spring integration approach
|
|
|
|
|
|
### 3.2.1 Configuration
|
|
@@ -749,6 +760,18 @@ public class SomeAppConfig {
|
|
|
public class AnotherAppConfig {}
|
|
|
```
|
|
|
|
|
|
+4.Support for multiple appid (added in version 2.4.0)
|
|
|
+```java
|
|
|
+// Added support for loading multiple appid their corresponding namespaces.
|
|
|
+// Note that when using multiple appid, if there are keys that are the same,
|
|
|
+// only the key from the prioritized loaded appid will be retrieved
|
|
|
+@Configuration
|
|
|
+@EnableApolloConfig(value = {"FX.apollo", "application.yml"},
|
|
|
+ multipleConfigs = {@MultipleConfig(appid = "ORDER_SERVICE", namespaces = {"ORDER.apollo"})}
|
|
|
+)
|
|
|
+public class SomeAppConfig {}
|
|
|
+```
|
|
|
+
|
|
|
#### 3.2.1.3 Spring Boot integration methods (recommended)
|
|
|
|
|
|
Spring Boot supports the above two integration methods in addition to configuration via application.properties/bootstrap.properties, which enables configuration to be injected at an earlier stage, such as scenarios that use `@ConditionalOnProperty` or have some spring-boot-starter needs to read the configuration to do something in the startup phase (e.g. [dubbo-spring-boot-project](https://github.com/apache/incubator-dubbo-spring-boot-project)). So for Spring Boot environment it is recommended to access Apollo (requires version 0.10.0 and above) by the following way.
|