From 109e731c8388dafa06159abc4744285b80c6f555 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 21 Nov 2024 13:31:20 +0000 Subject: [PATCH] Revert "Add `@ConditionalOnMissingBean` for `JobRepository`" This reverts commit 73fc351d71cc9120c794bf6206b389a4dbb4ba4c. See gh-43236 --- .../batch/BatchAutoConfiguration.java | 8 ------- .../batch/BatchAutoConfigurationTests.java | 21 ------------------- 2 files changed, 29 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index 0068e6397ec7..e09ab3e8de0e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -20,7 +20,6 @@ import javax.sql.DataSource; -import org.springframework.batch.core.configuration.BatchConfigurationException; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration; import org.springframework.batch.core.explore.JobExplorer; @@ -130,13 +129,6 @@ protected DataSource getDataSource() { return this.dataSource; } - @Bean - @ConditionalOnMissingBean - @Override - public JobRepository jobRepository() throws BatchConfigurationException { - return super.jobRepository(); - } - @Override protected PlatformTransactionManager getTransactionManager() { return this.transactionManager; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index 3595227c959d..8f10bea4e035 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -517,13 +517,6 @@ void defaultExecutionContextSerializerIsUsed() { }); } - @Test - void defaultJobRepositoryIsNotCreatedWhenUserDefinedJobRepositoryBean() { - this.contextRunner - .withUserConfiguration(TestConfigurationWithJobRepository.class, EmbeddedDataSourceConfiguration.class) - .run((context) -> assertThat(context).hasSingleBean(TestJobRepository.class)); - } - private JobLauncherApplicationRunner createInstance(String... registeredJobNames) { JobLauncherApplicationRunner runner = new JobLauncherApplicationRunner(mock(JobLauncher.class), mock(JobExplorer.class), mock(JobRepository.class)); @@ -603,16 +596,6 @@ static class TestConfiguration { } - @TestAutoConfigurationPackage(City.class) - static class TestConfigurationWithJobRepository { - - @Bean - TestJobRepository jobRepository() { - return mock(TestJobRepository.class); - } - - } - @Configuration(proxyBeanMethods = false) static class EntityManagerFactoryConfiguration { @@ -897,8 +880,4 @@ ExecutionContextSerializer executionContextSerializer() { } - interface TestJobRepository extends JobRepository { - - } - }