【发布时间】:2016-11-16 23:02:17
【问题描述】:
我有一个 launch-context.xml,它定义了 7 个不同的作业,所有这些作业都有相同的父级。它们有“jobA”、“jobB”等名称。
我试过了:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/launch-context.xml", "/OurBatchKernelTestConfig.xml" })
public class AllTest extends BaseRaptorBatchTest {
@Autowired
private JobLauncherTestUtils utils;
@Autowired
@Qualifier(value="jobA")
private Job job;
@Test
public void testLaunch() {
Properties p = new Properties(); // then I set these up.
JobExecution je = utils.launchJob(paraCvter.getJobParameters(p));
}
}
这不起作用。
我得到一个例外:
STDOUT [WARN ] [2015.04.15 11:14:42] support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobLauncherTestUtilsForSnapshot': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.batch.test.JobLauncherTestUtils.setJob(org.springframework.batch.core.Job); nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Job] is defined: expected single matching bean but found 2: coverageRuleBatch,generateMetricsSnapshotJob
我也试过了:
https://stackoverflow.com/a/29658577/869809
我试过了:
https://stackoverflow.com/a/36352437/869809
这些都不起作用。
我可以创建我的 launch-content.xml 的副本并删除其他作业。然后我在注释中提到它,一切都很好。但是我需要 7 个不同的 xml 文件。艾克。
【问题讨论】:
-
你解决过这个问题吗?
标签: java spring spring-batch spring-java-config