title: Junit spring boot unable to autowire jdbc template
body: <p>I have a Spring Boot application and worked fine with the application and previously with my JUNIT tests.</p>
  
  <p>I have recently started using a JDBCTemplate and DataSource all of the tests fail to even start.</p>
  
  <p>The main problem from the stacktrace is that once it tries to Autowire either the datasource or jdbc template it seems it cannot find the datasource properties</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'directoryLoader': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.jdbc.core.JdbcTemplate com.millerhare.winfsapi.fsloader.DirectoryLoader.jdbcTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
  
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
  ...
  </code></pre>
  
  <p>This is the Autowire class</p>
  
  <pre><code>@Component
  public class DirectoryLoader {
  
  
  @Autowired
  JdbcTemplate jdbcTemplate;
  
  @Autowired
  DataSource ds;
  </code></pre>
  
  <p>However in the application.properties for both the application and test, all of the datasource properties are set</p>
  
  <pre><code>spring.datasource.url=jdbc\:oracle\:thin\:@xxxx
  spring.datasource.username=xxxx
  spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
  </code></pre>
  
  <p>I have tried changing other properties like the server.port and those are picked up so it is clearly finding the application.properties file fine.</p>
  
  <p>My original configuration for the test was</p>
  
  <pre><code> @RunWith(SpringJUnit4ClassRunner.class)
   @SpringApplicationConfiguration(classes = WinFsapiApplication.class)
   @WebIntegrationTest
  </code></pre>
  
  <p>I have also tried setting the properties via <code>@TestPropertiesSource</code> but this also does not find them.
  What am I missing?</p>