Relocate @AutoConfigureDataSourceInitialization

Relocate `@AutoConfigureDataSourceInitialization` from
`spring-jdbc-test` to `spring-boot-test-autoconfigure`. This change
allows Flyway and Liquibase to respond to the annotation without
the user needing to remember the `spring-jdbc-test` dependency.

This is especially important for R2DB applications which may
still be using Flyway or Liquibase for migrations and will
want them to apply during tests.

See gh-46356
See gh-47322
This commit is contained in:
Phillip Webb
2025-10-01 21:43:13 -07:00
parent 8008076e04
commit 155e3bd5e6
15 changed files with 32 additions and 11 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.jdbc.test.autoconfigure;
package org.springframework.boot.test.autoconfigure.jdbc;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -0,0 +1,23 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-configuration for core JDBC test concerns.
*/
@NullMarked
package org.springframework.boot.test.autoconfigure.jdbc;
import org.jspecify.annotations.NullMarked;
@@ -28,7 +28,6 @@ dependencies {
api(project(":module:spring-boot-data-r2dbc"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":module:spring-boot-jdbc-test"))
optional("org.junit.jupiter:junit-jupiter-api")
testImplementation(project(":test-support:spring-boot-test-support"))
@@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data R2DBC
+1 -1
View File
@@ -33,8 +33,8 @@ dependencies {
optional(project(":core:spring-boot-autoconfigure"))
optional(project(":core:spring-boot-docker-compose"))
optional(project(":module:spring-boot-jdbc-test"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":core:spring-boot-test-autoconfigure"))
optional(project(":module:spring-boot-actuator-autoconfigure"))
optional("org.flywaydb:flyway-database-oracle")
optional("org.flywaydb:flyway-database-postgresql")
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
@@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical JDBC tests. Most
@@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical jOOQ tests. Most
+1 -1
View File
@@ -36,8 +36,8 @@ dependencies {
optional(project(":core:spring-boot-autoconfigure"))
optional(project(":core:spring-boot-docker-compose"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":core:spring-boot-test-autoconfigure"))
optional(project(":module:spring-boot-actuator-autoconfigure"))
optional(project(":module:spring-boot-jdbc-test"))
optional("org.testcontainers:jdbc")
dockerTestImplementation(project(":core:spring-boot-test"))
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
@@ -32,7 +32,6 @@ dependencies {
dockerTestImplementation(project(":core:spring-boot-testcontainers"))
dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test"))
dockerTestImplementation(project(":module:spring-boot-jdbc-test"))
dockerTestImplementation(project(":starter:spring-boot-starter-test"))
dockerTestImplementation(project(":test-support:spring-boot-docker-test-support"))
dockerTestImplementation("io.projectreactor:reactor-test")
@@ -30,7 +30,6 @@ dependencies {
dockerTestImplementation(project(":core:spring-boot-testcontainers"))
dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test"))
dockerTestImplementation(project(":module:spring-boot-jdbc-test"))
dockerTestImplementation(project(":starter:spring-boot-starter-test"))
dockerTestImplementation(project(":test-support:spring-boot-docker-test-support"))
dockerTestImplementation("io.projectreactor:reactor-test")