Use a environment variable in the spring property file

Viewed 3133

I am new to spring I have a awsCredentials.properties file.

AWS.Access.ID=value
AWS.Secret.ID=value

Now, I have already system environment variables in which I defined all the credentials. Now I want to use this is in the awsCredentials.properties file. So that Whenever I commit, then this credentials should not be in the git . But when I try to do it like -

AWS.Access.ID=${AWS_ACCESSKEY}  this is not working. 

can any one help me with this ?

1 Answers

as of now (May 2019) you can simply add the following:

AWS.Access.ID=${env.AWS_ACCESSKEY}

And spring should automagically read the value from the system environment. (at least it did for me without doing anything special in my config bean)

Related