title: spring boot: how to configure datasource from application properties
body: <p>I want the below code values: <code>DriverClassName</code>, <code>Url</code>, <code>Username</code>, <code>Password</code> to be read from <em>application.properties</em> file, how to do that? I am using Spring Boot, Mysql, Hibernate and Spring Rest.</p>
  
  <p><strong>DatasourceConfig.java</strong></p>
  
  <pre><code>    //This is working fine with inline value specified as below (DriverClassName, Url,Username,Password
      @Configuration
      @EnableTransactionManagement
      @EnableJpaRepositories(basePackages = "com.nouhoun.springboot.jwt.integration.repository")
      public class DatasourceConfig {
  
          @Bean
          public DataSource datasource() throws PropertyVetoException {
                 final DriverManagerDataSource dataSource = new DriverManagerDataSource();
                 dataSource.setDriverClassName("com.mysql.jdbc.Driver");
                 dataSource.setUrl("jdbc:mysql://localhost:3306/fdb?createDatabaseIfNotExist=true");
                 dataSource.setUsername("root");
                 dataSource.setPassword("");
                 return dataSource;
      }
     ....
     ....
     ....
  </code></pre>