I am trying to parameterize my file application.yml
so that I can put it in the github repository with my project, but did not find the details of connecting to the database. I want to use system environment variables for this. I am using OS X El Capitan.
I put the following lines in mine .bash_profile
:
export JDBC_TODO_USER=<my-username>
export JDBC_TODO_PASS=<my-password>
and the following lines in mine application.yml
:
spring:
datasource:
username: ${JDBC_TODO_USER}
password: ${JDBC_TODO_PASS}
I also tried
spring:
datasource:
username: ${JDBC.TODO.USER}
password: ${JDBC.TODO.PASS}
Both of them give me an error while starting the application:
java.sql.SQLInvalidAuthorizationSpecException: Could not connect: Access denied for user '${JDBC_TODO_USER'@'<my-ip-address>' (using password: YES)
Of course, when I replace ${JDBC_TODO_USER}
my username ${JDBC_TODO_PASS}
with my password, then everything works fine. It seems that Spring does not understand that I am related to environment variables. Do I need to do some additional configuration to make it work?