mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Merge branch '3.1.x'
Closes gh-38339
This commit is contained in:
commit
c66322491d
@ -20,14 +20,10 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
@ -95,20 +91,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) {
|
||||
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 {
|
||||
|
||||
|
@ -42,6 +42,7 @@ import org.springframework.batch.core.configuration.support.DefaultBatchConfigur
|
||||
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;
|
||||
@ -110,8 +111,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