繁体   English   中英

我们可以在单个spring boot应用程序中使用多个yaml文件吗?

[英]Can we use multiple yaml files in a single spring boot application?

我有一个yaml文件,可读取所有环境配置文件。 我需要另一个yaml文件来创建功能开关,可以在部署期间打开/关闭它。 以及如何在属性文件中定义功能开关。

是的,如果您使用spring profile ,则可以使用多个YAML文件。 例如,如果您使用以下标志启动JVM:

-Dspring.profiles.active=deployed,cassandra

它将拾取以下应用程序YAML文件:

application.ymlapplication-deployed.ymlapplication-cassandra.yml

另一种方法是通过在application.yml文件中添加此密钥,如下所示

spring:
  profiles:
    include:
      - student
      - address

您可以将yaml文件命名为

application-student.yml, application-address.yml

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM