Resources:
Https://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.4.0.RELEASE/single/spring-cloud-config.html
http://cloud.spring.io/spring-cloud-static/Camden.SR7/#_environment_repository
Environment repository--Environment Library
Where do you want to store configuration data for config server? The strategy for managing this behavior is to serve the Enviroment object EnvironmentRepository
. This enviroment is a shallow copy of the spring environment domain (including propertysources as the primary function). Environment resources are parameterized by three variables:
- {Application} maps to ' Spring.application.name ' on the client side;--{application} is mapped to the "Spring.application.name" of the clients;
- {Profile} maps to ' spring.profiles.active ' on the client (comma separated list);--{profile} mapped to the " Spring.profiles.active "(comma-separated list);
- {label} which is a server side feature labelling a ' versioned ' Set of config Files.--{label} is a service-side feature that marks a "versioned" set of profiles.
The repository implementation typically loads the configuration file from "Spring.config.name" like the Spring boot application, equivalent to the {application} parameter, while "Spring.profiles.active" is equivalent to {profiles} Parameters. The precedence rules for a profile are the same as in regular boot applications: The active profile takes precedence over the default configuration, and if there are multiple profiles, the last profile wins (such as adding entries to the map).
For example, a client application has this boot configuration:
Bootstrap.yml
Spring: application: name:foo profiles: active:dev,mysql
(typically with spring boot applications, these properties can also be set to environment variables or command-line parameters)
If the repository is file-based, the server creates a environment from APPLICATION.YML (shared between all clients) and foo.yml (with yoo.yml precedence). If there are documents in the Yaml file that point to the spring profile, the files are applied at a higher priority (in the order of the profiles listed), and if there is a profile-specific yaml (or attribute) file, the files have a higher precedence than the default values. The higher priority is converted to the Propertysource listed before environment. (These rules are the same for standalone spring boot applications).
Spring-cloud-config-server--environment Repository