【发布时间】:2015-11-28 15:51:28
【问题描述】:
我正在尝试在单个上下文文件中配置多个作业并并行运行它们。以下是配置
<batch:job id="ParallelJob" incrementer="runIdIncrementer" restartable="true">
<batch:split id="parallelprocessing" task-executor="taskExecutor">
<batch:flow>
<batch:step id="ParallelJob.step1" >
<batch:job ref="JobA" job-launcher="jobLauncher" job-parameters-extractor="jobParametersExtractor"/>
</batch:step>
</batch:flow>
<batch:flow>
<batch:step id="ParallelJob.step2" >
<batch:job ref="JobB" job-launcher="jobLauncher" job-parameters-extractor="jobParametersExtractor"/>
</batch:step>
</batch:flow>
</batch:split>
</batch:job>
<batch:job id="JobA" restartable="true">
<batch:step id="abc">
<batch:tasklet >
<batch:chunk reader="reader" writer="writer" processor="processor" />
</batch:tasklet>
</batch:step>
</batch:job>
<batch:job id="JobB" restartable="true">
<batch:step id="abc">
<batch:tasklet >
<batch:chunk reader="reader" writer="writer" processor="processor" />
</batch:tasklet>
</batch:step>
</batch:job>
我遇到异常说org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Job] is defined: expected single matching bean but found 3:ParallelJob,JobA,JobB。有人可以帮助我吗。参考http://docs.spring.io/spring-batch/reference/html/configureStep.html#split-flows
【问题讨论】:
-
问题出在其他地方。你在哪里注入/使用 Job?
-
我没有在其他任何地方注入它。上面提到的只是配置和使用 commandLineJobRunner.bat 启动 ParallelJob 类路径:META-INF/spring/batch-context.xml ParallelJob -next %* – @图纳基
-
您能否发布异常的整个堆栈跟踪。必须有一个 Bean,必须将另一个具有 Job-interface 的 Bean 注入其中。我假设这个注入没有名称限定,所以 Spring 不知道它应该注入三个作业 bean 中的哪一个。
标签: java spring parallel-processing spring-batch