Browse Source

Remove unnecessary JobOperator bean definition

See gh-38325
3.0.x
Lars Uffmann 2 years ago committed by Moritz Halbritter
parent
commit
e41b36273f
  1. 18
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java
  2. 4
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java

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

@ -18,14 +18,10 @@ package org.springframework.boot.autoconfigure.batch; @@ -18,14 +18,10 @@ package org.springframework.boot.autoconfigure.batch;
import javax.sql.DataSource;
import org.springframework.batch.core.configuration.ListableJobLocator;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
import org.springframework.batch.core.converter.JobParametersConverter;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.support.SimpleJobOperator;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ExitCodeGenerator;
@ -92,20 +88,6 @@ public class BatchAutoConfiguration { @@ -92,20 +88,6 @@ public class BatchAutoConfiguration {
return new JobExecutionExitCodeGenerator();
}
@Bean
@ConditionalOnMissingBean(JobOperator.class)
public SimpleJobOperator jobOperator(ObjectProvider<JobParametersConverter> jobParametersConverter,
JobExplorer jobExplorer, JobLauncher jobLauncher, ListableJobLocator jobRegistry,
JobRepository jobRepository) throws Exception {
SimpleJobOperator factory = new SimpleJobOperator();
factory.setJobExplorer(jobExplorer);
factory.setJobLauncher(jobLauncher);
factory.setJobRegistry(jobRegistry);
factory.setJobRepository(jobRepository);
jobParametersConverter.ifAvailable(factory::setJobParametersConverter);
return factory;
}
@Configuration(proxyBeanMethods = false)
static class SpringBootBatchConfiguration extends DefaultBatchConfiguration {

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

@ -41,6 +41,7 @@ import org.springframework.batch.core.configuration.support.JobRegistryBeanPostP @@ -41,6 +41,7 @@ import org.springframework.batch.core.configuration.support.JobRegistryBeanPostP
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.job.AbstractJob;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
@ -105,8 +106,11 @@ class BatchAutoConfigurationTests { @@ -105,8 +106,11 @@ class BatchAutoConfigurationTests {
this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(JobRepository.class);
assertThat(context).hasSingleBean(JobLauncher.class);
assertThat(context).hasSingleBean(JobExplorer.class);
assertThat(context).hasSingleBean(JobRegistry.class);
assertThat(context).hasSingleBean(JobOperator.class);
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
.isEqualTo(DatabaseInitializationMode.EMBEDDED);
assertThat(new JdbcTemplate(context.getBean(DataSource.class))

Loading…
Cancel
Save