Spring Boot Core configuration file bootstrap & application detailed.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.