【问题标题】:Spring batch JobStep is failing when configured with multiple jobs配置多个作业时,Spring 批处理 JobStep 失败
【发布时间】: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


【解决方案1】:

我能够解决这个问题。我将 Job 注入到我不再使用的类之一中

【讨论】:

    猜你喜欢
    • 2015-04-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    相关资源
    最近更新 更多