Spring boot 不读取环境特定的 YAML 文件 [英] Spring boot not reading environment specific YAML file
问题描述
我开发了一个 spring boot rest 应用程序,我正在尝试根据值spring.profiles.active"读取特定于环境的 YAML 文件
I have developed a spring boot rest application and I am trying to read the environment specific YAML file based on the value "spring.profiles.active"
我有两个文件
1. application.yml
2. application-qa.yml
并且我在两个文件中都有以下属性
and I have below property in both the files
application.yml 文件具有以下属性
comp:
bu:
env: local
application-qa.yml 文件具有以下属性
comp:
bu:
env: QA
并且我正在设置 spring.profiles.active=qa
,上面给出,我期望只有 application-qa.yml
被加载,但在这种情况下application.yml 和 application-qa.yml
正在加载,当我的代码查找属性 comp.bu.env 时,它总是获取值
and I am setting spring.profiles.active=qa
, given above, I was expecting that only application-qa.yml
gets loaded, but in this case both application.yml and application-qa.yml
are getting loaded and when my code looks for property comp.bu.env it is always getting the value
本地
只有
我希望我的代码从 application-qa.yml
文件中读取 comp.bu.env 属性.
I want my code to read the comp.bu.env property from application-qa.yml
file.
能帮我弄清楚我在这里遗漏了什么吗?
can some help to figure out what i am missing here?
推荐答案
感谢您的指点,我已经解决了.我在 application-qa.yml 中有 AWS 配置文件,这导致我的 QA 属性被跳过,因为我提供的配置文件名称是 QA.我已将我的属性移到 application-qa.yml 文件中的 AWS:profile 上方,然后这些属性开始出现.
Thanks for your points, I have solved it. I have AWS profile in application-qa.yml which is causing my QA properties to be skipped because the profile name I have supplied is QA. I have moved my properties above the AWS:profile in application-qa.yml file then those properties started picking up.
这篇关于Spring boot 不读取环境特定的 YAML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!