SpringCloud Study Notes (2) -- Config, springcloud Study Notes
Refer to Spring Cloud official documentation 4th ~ Chapter 10
The configurations in all examples in the official website are on git.
Https://github.com/spring-cloud-samples/config-repo
Part II. Spring Cloud Config4. Quick Start
The default policy for finding the location of a property resource is to clone a git repository and use it to initialize a minimum SpringApplication.
4.1 Client Side Usage
When the program runs, it captures external configurations. By default, it captures local configurations from the local port 8888. You can change this configuration in the bootstrap. properties file. Bootstrap. properties is the context of the program startup phase. Simply put, bootstrap. properties will be loaded before the application. properties file is started.
5. Spring Cloud Config Server
The server provides HTTP to obtain external configurations (key-value pairs or content in YAML format) through resource APIs ). Spring Boot embeds this operation through @ EnableConfigServer.
5.1 Environment Repository
When Spring Boot loads the configuration, "spring. cloud. name" is equivalent to {application}, and "spring. profiles. active" is equivalent to {profile}
In the repository, you can save the configuration file to a subdirectory and retrieve it through pattern matching.
In addition, placeholders can be used in the Git URL path and in the search path.
10. Spring Cloud Config Client
10.1 Config First Bootstrap
10.2 Discovery First Bootstrap
10.5 Locating Remote Configuration Resources
Code on
Three projects are required: eureka-server-demo, config-server-demo, and config-client-demo. Needless to say, the first one focuses on the next two.
First, configure config-server-demo
Then, configure config-client-demo
Start the three projects respectively
Haha! Successful !!!
Reference
Http://blog.csdn.net/qq_22841811/article/details/67637796