Search code examples
javaspringspring-bootapache-camelspring-config

How to inject a string that contains ${...} in spring application.properites


How to inject a string that contains ${...} in spring application.properites

I wanted to provide following key value pair in the applicaiton.properties file in spring and wanted spring to ignore the place holder without resolving it.

output.folder=${date:now:yyyy-MM-dd}/success/${header.CamelFileName} 

But while loading spring is trying to provide the place holder value, for instance header.CamelFileName and would throw exception. Is there any way this can be escaped?


Solution

  • You can try something like this, to escape a placeholder:

    $=$
    output.folder=${date:now:yyyy-MM-dd}/success/${$}{header.CamelFileName} 
    

    It could look a little bit tricky, but you have to escape a dollar sign, in order not to turn a ${header.CamelFileName} into reference