-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Version: Spring Boot v2.2.1.RELEASE, Spring v5.2.1.RELEASE
Hi, I'm using @DataJpaTest
with default embedded H2 DB for testing. Also I'm creating DB schema using schema.sql
which contains CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA;
.
Unit tests annotated with the @DataJpaTest
ran fine until I added to my production application.properties
properties spring.datasource.schema-username=${DB_USERNAME_SCH}
and spring.datasource.schema-password=${DB_PASSWORD_SCH}
.
This causes that a datasource based on the application.properties is trying to be created instead of the default H2 database. The creation of DB from application.properties fails because the datasource configuration looks like this:
spring.datasource.driver-class-name= oracle.jdbc.OracleDriver
spring.datasource.url= ${DB_URL}
spring.datasource.username= ${DB_USERNAME}
spring.datasource.password= ${DB_PASSWORD}
spring.datasource.schema-username= ${DB_USERNAME_SCH}
spring.datasource.schema-password= ${DB_PASSWORD_SCH}
I would expect that the embedded H2 is used even if the schema-username and schema-password is used.
Source code which caueses the problem:
org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java:197 which is called from org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java:101