I am currently working on a spring loading project that uses a spring batch. I am trying to use JavaConfig instead of XML, but it is difficult with all the documents currently in XML.
I followed https://blog.codecentric.de/en/2013/06/spring-batch-2-2-javaconfig-part-5-modular-configurations, but I am having difficulty using it JobLauncherTestUtils. I know that I have to tell the test to use the correct spring context, but I cannot figure out how to do this. I get the following error:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.batch.test.JobLauncherTestUtils' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
My test is as follows:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MyApplication.class, MyJobConfiguration.class})
public class RetrieveDividendsTest {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Test
public void testSomething() throws Exception {
jobLauncherTestUtils.launchJob();
}
}
source
share