关键是JobLauncherTestUtils的配置:
@Configuration
public class BatchTestConfiguration {
@Bean
public JobLauncherTestUtils stoppedReportJobLauncherTestUtils(
JobLauncher stoppedReportJobLauncher
) {
return new JobLauncherTestUtils() {
@Autowired
public void setJobLauncher(JobLauncher stoppedReportJobLauncher) {
super.setJobLauncher(stoppedReportJobLauncher);
}
@Autowired
public void setJob(Job stoppedReportJob) {
super.setJob(stoppedReportJob);
}
};
}
}