Spring boot is known to have the following two configuration files in spring boot
- Bootstrap (. yml or. Properties)
- Application (. yml or. Properties)
Why do you have both of these configuration files? Is everyone aware of their differences and specific usage scenarios?
The difference between bootstrap/application
Deliberately went through the spring Boot Official document, did not find a specific definition of the two files, and then turned over the spring Cloud official documents found the difference.
Http://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_the_bootstrap_application_context
Read the following document carefully, the original is probably the meaning of this.
Spring Cloud is built on spring boot, there are two contexts in spring boot, one is bootstrap, the other is application, bootstrap is the parent context of the application, which means Bootstra P loading takes precedence over Applicaton. Bootstrap is primarily used to load configuration information from additional resources and to decrypt properties in a local external configuration file. The two contexts share an environment, which is the source of the external properties of any spring application. The properties inside the bootstrap are loaded first, and they cannot be overwritten by the same configuration locally.
Therefore, comparing the application configuration file, the bootstrap configuration file has several features.
- Boostrap loaded by parent ApplicationContext, more than Applicaton
- The attributes inside the boostrap cannot be overwritten.
Bootstrap/application's application Scenario
The application configuration file is easy to understand and is primarily used for the automation configuration of the Spring Boot project.
The bootstrap configuration file has several scenarios.
- When you use the Spring Cloud Config Configuration center, you need to add configuration properties that are connected to the configuration center in the bootstrap configuration file to load configuration information for the external configuration center;
- Some fixed properties that cannot be overridden
- Some encryption/decryption scenarios;
The following is a foreign netizen asked a Spring Cloud engineer to get the answer.
A friend of spring cloud microservices should be very clear about the application of bootstrap, and we have a practical tutorial on spring cloud that we can see in the Spring project.
Recommended: Spring Boot & Cloud's Strongest technology tutorials
Scan attention to our public number, dry foods updated daily.
Spring Boot Core configuration file bootstrap & application detailed.