title: How to externalize application.properties to an external filesystem location in Spring Boot?
body: <pre><code>@ComponentScan
  @EnableAutoConfiguration
  @PropertySource(value = { "file:/Users/Documents/workspace/application.properties" })
  
  public class Application  extends SpringBootServletInitializer{
      public static void main(String[] args) {
          ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
      }
  </code></pre>
  
  <p>In this case it gives while deploying:</p>
  
  <pre><code>org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency:
  </code></pre>
  
  <p>Not able to find the correct way to externalize the application properties file</p>
  
  <p>I tried autowiring environment variable which is correctly loaded but then I need to manually define all the beans</p>
  
  <pre><code>@Bean 
  public JdbcTemplate dataSource() {
      String driverClassName = env
              .getProperty("spring.datasource.driverClassName");
      String dsUrl = env.getProperty("spring.datasource.url");
      String username = env.getProperty("spring.datasource.username");
      String password = env.getProperty("spring.datasource.password");
      //DataSource dataSource = new SimpleDriverDataSource(new driverClassName, dsUrl, username, password);
      JdbcTemplate jdbc = new JdbcTemplate(dataSource);
      return jdbc;
  
  }
  </code></pre>
  
  <p>This deploys without throwing error but not responding.</p>