I have this property in my application.property file
logfile.dir=/Users/Nunito/logs/bonanza/ I would like to know if it is possible to do something like:
logfile.dir=/Users/{userName}/logs/bonanza/ Of course you can read environment variables from properties file. Provided username is configured as environment variable in the system you want to execute the code on.
simply replace,
this: logfile.dir=/Users/Nunito/logs/icrypts/
with: logfile.dir=/Users/${userName}/logs/icrypts/
You can also read properties file using any of below ways.
@Value("${username}") private String username; You can also use, SPRING_APPLICATION_JSON
At application startup, Spring Boot will look for an environment variable called SPRING_APPLICATION_JSON. It can be used to provide a set of application properties using inline JSON. For example, you can set ec2.public.url property as follows.
You can refer samples from here, https://github.com/indrekots/spring-boot-envvariables