美文网首页springboot学习
application.yml vs bootstrap.yml

application.yml vs bootstrap.yml

作者: CuiCat | 来源:发表于2017-03-15 22:27 被阅读0次

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

    本文链接:https://www.haomeiwen.com/subject/xqbrnttx.html