The default property source for external configurations added by the boot process is config Server, but you can add additional sources by adding propertysourcelocator-type beans to the boot context (via Spring.factories). You can use this method to insert additional properties from other servers or databases.
As an example, consider the following trivial custom locators:
@Configurationpublic class CustomPropertySourceLocator implements PropertySourceLocator { @Override public PropertySource<?> locate(Environment environment) { return new MapPropertySource("customProperty", Collections.<String, Object>singletonMap("property.from.sample.custom.source", "worked as intended")); }}
The incoming environment is the environment of the ApplicationContext to be created, which gives us an additional attribute source. It will already have a source of resources that normal spring boot provides, So you can use them to locate a property source specific to this environment (for example, by binding it on spring.application.name, such as the Config server property source locator by default).
If you create a jar in this class, then add a meta-inf/spring.factories containing:
org.springframework.cloud.bootstrap.BootstrapConfiguration=sample.custom.CustomPropertySourceLocator
Then the "CustomProperty" Propertysource will appear in any application that contains the jar in its classpath.
Spring Cloud Custom Boot Property source