Reputation: 447
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. ?
Upvotes: 2
Views: 2761
Reputation: 6391
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.
Upvotes: 2