title: Spring boot configuration with environment variables
body: <p>I have a spring boot application which interacts with DB to provide resource using Spring data Rest. I want to get the configuration from environment variables. Below is my properties file.</p>
  
  <pre><code>spring.datasource.url=${mysql.url}
  spring.datasource.username=${mysql.user}
  spring.datasource.password=${mysql.password}
  </code></pre>
  
  <p>And my environment variables are in the image <a href="https://ibb.co/cyxsNc" rel="noreferrer">https://ibb.co/cyxsNc</a></p>
  
  <p>I even tried with the below config too</p>
  
  <pre><code>spring.datasource.url=${MySQL_Url}
  spring.datasource.username=${MySQL_User}
  spring.datasource.password=${MySQL_Password}
  </code></pre>
  
  <p>But I am not able to connect to the DB and getting the below error</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
  </code></pre>
  
  <p>Application folder structure</p>
  
  <pre><code>Project
  |-- src/main/java
      |-- com.example.app
          |-- DemoApplication.java
  |-- src/main/resources
      |-- application.properties
  </code></pre>
  
  <p>Note: The configuration works fine if I set the values like below</p>
  
  <pre><code>spring.datasource.url=jdbc:mysql://localhost:3306/ex_man
  spring.datasource.username=root
  spring.datasource.password=root
  </code></pre>
  
  <p>What am I missing?</p>