title: Spring Boot - using environment variables in application.yml
body: <p>I'm trying to parametrize my <code>application.yml</code> file so I can put it on github repo with my project, but not reveal database connection details. I want to use system environment variables to do so. I use OS X El Capitan.</p>
  
  <p>I put following lines in my <code>.bash_profile</code>:</p>
  
  <pre><code>export JDBC_TODO_USER=&lt;my-username&gt;
  export JDBC_TODO_PASS=&lt;my-password&gt;
  </code></pre>
  
  <p>and following lines in my <code>application.yml</code>:</p>
  
  <pre><code>spring:
     datasource:
     username: ${JDBC_TODO_USER}
     password: ${JDBC_TODO_PASS}
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>spring:
     datasource:
     username: ${JDBC.TODO.USER}
     password: ${JDBC.TODO.PASS}
  </code></pre>
  
  <p>Both of those give me an error during start of the app:
  <code>java.sql.SQLInvalidAuthorizationSpecException: Could not connect: Access denied for user '${JDBC_TODO_USER'@'&lt;my-ip-address&gt;' (using password: YES)</code></p>
  
  <p>Of course, when I replace <code>${JDBC_TODO_USER}</code> with my username and <code>${JDBC_TODO_PASS}</code> with my password then everything works fine. It looks like Spring does not understand that I refer to environment variables. Do I need to do some additional configuration to make it work?</p>