在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别? [英] What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?
问题描述
在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别?在 logging.config 情况下,应用程序的工作方式不同.
What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? In logging.config case, the application works different.
推荐答案
我刚刚问了 Spring Cloud
的人,我想我应该分享我在这里的信息.
I have just asked the Spring Cloud
guys and thought I should share the info I have here.
bootstrap.yml
在 application.yml
之前加载.
bootstrap.yml
is loaded before application.yml
.
通常用于以下情况:
- 当使用Spring Cloud Config Server时,你应该在
bootstrap中指定
spring.application.name
和spring.cloud.config.server.git.uri
.yml - 一些
加密/解密
信息
- when using Spring Cloud Config Server, you should specify
spring.application.name
andspring.cloud.config.server.git.uri
insidebootstrap.yml
- some
encryption/decryption
information
从技术上讲,bootstrap.yml
是由父 Spring ApplicationContext
加载的.该父 ApplicationContext
在使用 application.yml
的那个之前加载.
Technically, bootstrap.yml
is loaded by a parent Spring ApplicationContext
. That parent ApplicationContext
is loaded before the one that uses application.yml
.
这篇关于在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!