Search code examples
javaspringspring-bootjdbcdatasource

In a Spring test, how to enable the Data Source auto-configuration?


I have a Spring Boot application.

I have a JUnit test with a custom Spring context configuration.

How can I enable the JDBC Data Source auto-configuration from the Spring properties like spring.datasource.url, spring.datasource.username, …?


Solution

  • After adding EnableJpaRepositories to my test, the data source was initialized.