How to use system environment variable as part of @PropertySource value?

I want to run my program using java ... -Denv=prod ... and

 @PropertySource("classpath:/settings/$idontknowwhat$/database.properties")` 

read the properties file: /settings/prod/database.properties

I tried using #{systemProperties['env']} , but it is not allowed with the exception:

 Could not open ServletContext resource ['classpath:/settings/#{systemProperties['env']}/database.properties] 
+6
source share
1 answer

Found, I can just use

 @PropertySource("classpath:/settings/${env}/database.properties") 
+7
source

Source: https://habr.com/ru/post/976792/


All Articles