diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceCheckpointRestoreConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceCheckpointRestoreConfiguration.java index 6156ea5915..79d1a048b8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceCheckpointRestoreConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceCheckpointRestoreConfiguration.java @@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnCheckpointRestore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.jdbc.HikariCheckpointRestoreLifecycle; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -33,17 +32,14 @@ import org.springframework.context.annotation.Configuration; * Checkpoint-restore specific configuration. * * @author Olga Maciaszek-Sharma - * @since 3.2.0 */ @Configuration(proxyBeanMethods = false) @ConditionalOnCheckpointRestore @ConditionalOnBean(DataSource.class) -public class DataSourceCheckpointRestoreConfiguration { +class DataSourceCheckpointRestoreConfiguration { @Configuration(proxyBeanMethods = false) @ConditionalOnClass(HikariDataSource.class) - @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", - matchIfMissing = true) static class Hikari { @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceConfigurationTests.java index 17f5183ae3..3019be5437 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceConfigurationTests.java @@ -140,21 +140,19 @@ class HikariDataSourceConfigurationTests { @ClassPathOverrides("org.crac:crac:1.3.0") void whenCheckpointRestoreIsAvailableAndDataSourceHasBeenWrappedHikariAutoConfigRegistersLifecycleBean() { this.contextRunner.withUserConfiguration(DataSourceWrapperConfiguration.class) - .withPropertyValues("spring.datasource.type=" + HikariDataSource.class.getName()) .run((context) -> assertThat(context).hasSingleBean(HikariCheckpointRestoreLifecycle.class)); } @Test void whenCheckpointRestoreIsNotAvailableHikariAutoConfigDoesNotRegisterLifecycleBean() { - this.contextRunner.withPropertyValues("spring.datasource.type=" + HikariDataSource.class.getName()) + this.contextRunner .run((context) -> assertThat(context).doesNotHaveBean(HikariCheckpointRestoreLifecycle.class)); } @Test @ClassPathOverrides("org.crac:crac:1.3.0") - void whenCheckpointRestoreIsAvailableAndDataSourceInstantiatedByUserHikariAutoConfigRegistersLifecycleBean() { + void whenCheckpointRestoreIsAvailableAndDataSourceIsFromUserConfigurationHikariAutoConfigRegistersLifecycleBean() { this.contextRunner.withUserConfiguration(UserDataSourceConfiguration.class) - .withPropertyValues("spring.datasource.type=" + HikariDataSource.class.getName()) .run((context) -> assertThat(context).hasSingleBean(HikariCheckpointRestoreLifecycle.class)); }