Skip to content

Commit 3406391

Browse files
committed
Merge pull request #38325 from cachescrubber
* pr/38325: Remove unnecessary JobOperator bean definition Closes gh-38325
2 parents 1022e1b + e41b362 commit 3406391

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818

1919
import javax.sql.DataSource;
2020

21-
import org.springframework.batch.core.configuration.ListableJobLocator;
2221
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2322
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
24-
import org.springframework.batch.core.converter.JobParametersConverter;
2523
import org.springframework.batch.core.explore.JobExplorer;
2624
import org.springframework.batch.core.launch.JobLauncher;
27-
import org.springframework.batch.core.launch.JobOperator;
28-
import org.springframework.batch.core.launch.support.SimpleJobOperator;
2925
import org.springframework.batch.core.repository.JobRepository;
3026
import org.springframework.beans.factory.ObjectProvider;
3127
import org.springframework.boot.ExitCodeGenerator;
@@ -92,20 +88,6 @@ public JobExecutionExitCodeGenerator jobExecutionExitCodeGenerator() {
9288
return new JobExecutionExitCodeGenerator();
9389
}
9490

95-
@Bean
96-
@ConditionalOnMissingBean(JobOperator.class)
97-
public SimpleJobOperator jobOperator(ObjectProvider<JobParametersConverter> jobParametersConverter,
98-
JobExplorer jobExplorer, JobLauncher jobLauncher, ListableJobLocator jobRegistry,
99-
JobRepository jobRepository) throws Exception {
100-
SimpleJobOperator factory = new SimpleJobOperator();
101-
factory.setJobExplorer(jobExplorer);
102-
factory.setJobLauncher(jobLauncher);
103-
factory.setJobRegistry(jobRegistry);
104-
factory.setJobRepository(jobRepository);
105-
jobParametersConverter.ifAvailable(factory::setJobParametersConverter);
106-
return factory;
107-
}
108-
10991
@Configuration(proxyBeanMethods = false)
11092
static class SpringBootBatchConfiguration extends DefaultBatchConfiguration {
11193

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.batch.core.explore.JobExplorer;
4242
import org.springframework.batch.core.job.AbstractJob;
4343
import org.springframework.batch.core.launch.JobLauncher;
44+
import org.springframework.batch.core.launch.JobOperator;
4445
import org.springframework.batch.core.repository.JobRepository;
4546
import org.springframework.beans.BeansException;
4647
import org.springframework.beans.factory.annotation.Autowired;
@@ -105,8 +106,11 @@ void testDefaultContext() {
105106
this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
106107
.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
107108
.run((context) -> {
109+
assertThat(context).hasSingleBean(JobRepository.class);
108110
assertThat(context).hasSingleBean(JobLauncher.class);
109111
assertThat(context).hasSingleBean(JobExplorer.class);
112+
assertThat(context).hasSingleBean(JobRegistry.class);
113+
assertThat(context).hasSingleBean(JobOperator.class);
110114
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
111115
.isEqualTo(DatabaseInitializationMode.EMBEDDED);
112116
assertThat(new JdbcTemplate(context.getBean(DataSource.class))

0 commit comments

Comments
 (0)