在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别? [英] What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

查看:43
本文介绍了在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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.ymlapplication.yml 之前加载.

bootstrap.yml is loaded before application.yml.

通常用于以下情况:

  • 当使用Spring Cloud Config Server时,你应该在bootstrap中指定spring.application.namespring.cloud.config.server.git.uri.yml
  • 一些加密/解密信息
  • when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆