Use environment variable in spring properties file

I'm new to spring

I have a file awsCredentials.properties

.

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

      

Now I already have the system environment variables in which I have defined all the credentials. Now I want to use this in a file awsCredentials.properties

. So whenever I commit, these credentials shouldn't be in git. But when I try to do it like -

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

      

can anyone help me with this?

+3


source to share


1 answer


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

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

      



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

0


source







All Articles