简体   繁体   English

在 spring-cloud 项目中,可以完全用 bootstrap.yml 替换 application.yml 吗?

[英]In spring-cloud project, is it ok to replace application.yml with bootstrap.yml totally?

In spring-cloud projects, for some reason, need to put some properties into bootstrap.yml , so that to make the specific properties available earlier.spring-cloud项目中,出于某种原因,需要将一些属性放入bootstrap.yml中,以便更早地使特定属性可用。

Then there are 2 config files: bootstrap.yml and application.yml .然后有 2 个配置文件: bootstrap.ymlapplication.yml

Wondering is it ok to put everying into bootstrap.yml , and remove application.yml totally, to make it cleaner.想知道是否可以将所有内容放入bootstrap.yml并完全删除application.yml以使其更清洁。

Since bootstramp.yml is just loaded earlier, it seems to be ok, right?由于bootstramp.yml只是之前加载的,所以似乎没问题,对吧? Or, will this cause some issue in some case?或者,这会在某些情况下引起一些问题吗?

Basically idea is to get configurations from ConfigServer using Spring Cloud Config.基本上想法是使用 Spring Cloud Config 从ConfigServer获取配置。 But sometimes we need some configurations eg spring.application.name upfront so, I'm using those configurations in bootstrap.yml .但有时我们需要一些配置,例如spring.application.name ,所以我在bootstrap.yml中使用这些配置。 Which generally overrides what's in an application.yml [if present]).这通常会覆盖 application.yml [如果存在] 中的内容)。 Reference参考

Plus, yes you can put all your configurations in bootstrap.yml and it works simply fine.另外,是的,您可以将所有配置放在bootstrap.yml中,它工作得很好。 I've tested with more than four microservices.我已经测试了超过四个微服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 spring boot 中将属性放在 application.yml 或 bootstrap.yml 上有什么区别? - What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? Spring Cloud 2020.0 不再处理 bootstrap.yml 配置 - bootstrap.yml configuration not processed anymore with Spring Cloud 2020.0 bootstrap.yml 未在 Spring Boot 2 中加载 - bootstrap.yml not loading in Spring Boot 2 是否需要 bootstrap.yml? - Is bootstrap.yml required? 如何在 application.yml Spring Cloud Gateway 中指定自定义过滤器 - How to Specify custom filter in application.yml Spring Cloud Gateway Heroku上的Spring Boot项目无法使用application.yml - Spring boot project on Heroku unable to use application.yml 使用Java而不是bootstrap.yml通过Eureka查找Spring Cloud Config Server - Spring Cloud Config Server lookup through Eureka using Java instead of bootstrap.yml 在bootstrap.yml中不使用spring.application.name,在冲突情况下在application.properties中使用 - spring.application.name is not honoured in bootstrap.yml instead honoured in application.properties in conflicting case Spring 引导:使用 bootstrap.yml 加载通用配置应用程序属性文件 - Spring Boot: Load common config application properties file using bootstrap.yml 在 Spring 上未找到/读取 Bootstrap.yml 部署在 Tomcat 上的 Boot 2 应用程序 - Bootstrap.yml not being found/read on Spring Boot 2 application deployed on Tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM