简体   繁体   中英

Spring Boot doesn't resolve property placeholder in yaml for apring.profiles.active property

I am used to feature that I can refer to another property from within.yml file using ${...} . So I have Spring Boot v2.3.0.RELEASE and following.yml:

env: dev
spring:
  profiles:
    active: ${env}

But unfortunately, when running my application i see

The following profiles are active: ${env}

Despite the fact that this placeholder works perfectly in other properties, for example kafka topics i define as

topic: ${env}.topic_name

and i can see in logs that it's resolved properly

Kafka producer topic=dev.topi_name

Seems like spring.profiles.active is some sort of an exception from this rule, but i can't find why. And how can i get the same result (with profile depending on other property variable) as is, without env variables, external keys, setting in code, etc. ?

This problem has been fixed in Spring Boot 2.4.0 as a part of the updated config file processing (more about it in 2.4.0 release notes ).

If interested, you can play with the new property spring.config.use-legacy-processing to see the difference in how spring.profiles.active is processed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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