Search code examples
spring-bootpropertiesyaml

Is there way to build variable value based on another variable value in application.yaml?


Let's say I have following application.yaml:

my:
  key1: key1Value
  key2: key2Value
  key3: key1 + _ + key2

It is an attemp to assign the property my.key3="key1Value_key2Value"

But it doesn't work.

Is there way in spring-boot to have such kind of references in application.yml ?


Solution

  • You can use property placeholders in the application.yaml as follows:

    my:
      key1: key1Value
      key2: key2Value
      key3: ${my.key1}_${my.key2}