我写春天批次application.Code JUnit的测试用例下面异常在JUnit的情况下实现了Spring Batch的
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { AppTest.BatchTestConfig.class })
public class AppTest {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Test
public void demo() throws Exception {
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
}
@Configuration
@EnableBatchProcessing
static class BatchTestConfig {
@Bean
JobLauncherTestUtils jobLauncherTestUtils() {
return new JobLauncherTestUtils();
}
}
}
给定,但是相同的是给予例外如下:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'jobLauncherTestUtils':
Unsatisfied dependency expressed through method 'setJob' parameter 0;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.springframework.batch.core.Job' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
请建议
什么'Job'你期待执行? –
嗨..我只有一个工作在我的春天批处理应用程序。但我不知道如何执行它在Junit.CanüPLZ告诉我 –