Search code examples
javaspring-bootspring-cloud-config

Spring Cloud Config encrypted property as default value


Having application.yml like this:

foo.bar: '{cipher}aaa'

works OK.

I'd like to use the encrypted value as a default only. So something like:

foo.bar: '${xyz:{cipher}aaa}'

This however doesn't work, as the {cipher}aaa part is not recognized as encrypted.

How should I fix it?


Solution

  • The {cipher} bit is only recognized at the beginning of a property. Try setting

    foo.bar.default: {cipher}aaa
    foo.bar: '${xyz:${foo.bar.default}}'