1

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/ 

2 Answers 2

1

It's possible. Just use ${userName}.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.