我寫春天批次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告訴我 –