title: spring boot usage of placeholder in application properties
body: <p>I have written a simple spring boot application(version springboot 2.0) which uses mysql(version 5.7).</p>
  
  <p><strong>application.properties</strong> snippet</p>
  
  <pre><code>spring.datasource.url = jdbc:mysql://localhost:3306/test?useSSL=false
  spring.datasource.username = testuser
  spring.datasource.password = testpassword
  spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  </code></pre>
  
  <p>When I run it locally, it works fine.
  If I want to run this spring boot application in docker then I can change</p>
  
  <pre><code>spring.datasource.url = jdbc:mysql://mysql-container:3306/test?useSSL=false
  </code></pre>
  
  <p><em>mysql-container is run using mysql:5.7 image from dockerhub.</em></p>
  
  <p>However I want to change value of host from some placeholder properties file. so that this looks something like:</p>
  
  <pre><code>spring.datasource.url = jdbc:mysql://${MYSQL_HOST}:3306/test?useSSL=false
  </code></pre>
  
  <p>note: I am not sure about placeholder format. Is it ${MYSQL_HOST} or @MYSQL_HOST@ ?</p>
  
  <p>you can name this placeholder file as <em>placeholder.properties</em> or <em>placeholder.conf</em> or <em>.env</em> or anything. The content of that file should be something like:</p>
  
  <pre><code>MYSQL_HOST=localhost
  </code></pre>
  
  <p>or</p>
  
  <pre><code>MYSQL_HOST=some ip address
  </code></pre>
  
  <p>I can create .env or .env.test or .env.prod and I can refer that env file based on where I want to run application.</p>
  
  <hr>
  
  <p>UPDATE -</p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>Where should I keep placeholder.properties? Is it under /config/ or under some specific directory?</p></li>
  <li><p>how to invoke placeholder inside application.properties ?</p></li>
  </ol>
  
  <p>can someone suggest?</p>