diff --git a/spring-boot-project/spring-boot/pom.xml b/spring-boot-project/spring-boot/pom.xml index cb3d81a582..e42cf62672 100644 --- a/spring-boot-project/spring-boot/pom.xml +++ b/spring-boot-project/spring-boot/pom.xml @@ -472,6 +472,21 @@ spring-data-redis test + + org.testcontainers + jdbc + test + + + javax.annotation + javax.annotation-api + + + javax.xml.bind + jaxb-api + + + org.xerial sqlite-jdbc diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index fa134ddef4..3470154b5a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java @@ -196,6 +196,18 @@ public enum DatabaseDriver { return Arrays.asList("informix-sqli", "informix-direct"); } + }, + + /** + * Testcontainers. + */ + TESTCONTAINERS(null, "org.testcontainers.jdbc.ContainerDatabaseDriver") { + + @Override + protected Collection getUrlPrefixes() { + return Collections.singleton("tc"); + } + }; private final String productName; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java index ce870dfb01..0307a3a550 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java @@ -112,6 +112,8 @@ class DatabaseDriverTests { assertThat(DatabaseDriver.fromJdbcUrl("jdbc:informix-sqli://localhost:1533/sample")) .isEqualTo(DatabaseDriver.INFORMIX); assertThat(DatabaseDriver.fromJdbcUrl("jdbc:informix-direct://sample")).isEqualTo(DatabaseDriver.INFORMIX); + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:tc:mysql://localhost:3306/sample")) + .isEqualTo(DatabaseDriver.TESTCONTAINERS); } }