Botstrap and application are configuration files in the SpringBoot project. Their differences mainly include the following aspects
The bootstrap configuration file is loaded prior to the application configuration file, because bootstrap is loaded by the spring parent context, and application is loaded by the child context
The configuration information loaded by bootstrap cannot be overwritten by the same configuration of application. If two configuration files exist at the same time, bootstrap will be the main one
1. Configure some fixed properties that cannot be overridden. Used for some system-level parameter configuration
The local configuration file cannot overwrite the remote configuration by default. ’s
2. Some scenarios that require encryption/decryption
3. When you use the Spring Cloud Config configuration center, you need to add the configuration connected to the configuration center in the boostrap configuration file. Properties to load the configuration information of the external configuration center, the professional translation is as follows
application common application scenarios
1. Commonly used in SpringBoot projects Automated configuration
2. Used for some application-level parameter configuration
In most cases, there is no need to distinguish between the two situations, just use application, and the effect is basically the same
bootstrap.yml precedes application.yml.
In the ApplicationContext boot phase, bootstrap.yml can be used. Spring application context is loaded by the parent context ApplicationContext. Defines system-level parameter configurations. These parameters generally do not change.
application.yml is used to define application-level parameter configuration. When used with spring-cloud-config, parameters defined in application.yml can be dynamically replaced.
application.yml will override the parameter configuration of bootstrap.yml.
From the inside to the outside, the outer layer covers the inner layer.
Command line parameters> Operating system environment variables> Configuration files outside the application> Configuration files within the application
Configuration center> Command line parameters> local application.yml > local bootstrap.yml
Configuration allows override:
spring: cloud: config: allowOverride: true overrideNone: true overrideSystemProperties: false
The above is the detailed content of What is the difference between bootstrap and application in SpringBoot?. For more information, please follow other related articles on the PHP Chinese website!