mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Remove unnecessary JobOperator bean definition
See gh-38325
This commit is contained in:
parent
1022e1bdd2
commit
e41b36273f
@ -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 {
|
||||
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 {
|
||||
|
||||
|
@ -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 {
|
||||
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…
Reference in New Issue
Block a user