application.yml vs bootstrap.yml in spring boot

What is the diference between putting a property on application.yml or bootstrap.yml in spring boot?


Bootstrap.yml (bootstrap.properties) is loaded before application.yml (application.properties),it's like application.yml but for the bootstrap phase of an application context. It is typically used for the case "when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.yml", and also some encryption/decryption information.Technically, bootstrap.yml is loaded by a parent Spring ApplicationContext. That parent ApplicationContext is loaded before the one that uses application.yml.

For example, when using Spring Cloud, the 'real' configuration data is usually loaded from a server. In order to get the URL (and other connection configuration, such as passwords, etc.), you need an earlier or "bootstrap" configuration. Thus, you put the config server attributes in the bootstrap.yml, which is used to load the real configuration data (which generally overrides what's in an application.yml [if present]).

你可能感兴趣的:(application.yml vs bootstrap.yml in spring boot)