当我尝试将jobExecutioncontext中的值分配给commit-interval时,我收到以下错误。
<chunk reader="itemREader" writer="itemwriter" commit-interval="#{jobExecutionContext[rowcount]}">
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'jobExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
从jobParameters中获取相同的错误。
通过创建扩展SimpleCompletionPolicy并从jobExecutioncontext传递值的自定义策略类来尝试使用chunk-completion-policy。当我运行作业时,步骤已开始但未完成继续运行。
<bean id="myCompletionPolicy"
class="com.vn.src.service.myCompletionPolicy" scope="step">
<property name="recordCount" value="#{jobExecutionContext[RowCount]}"/>
</bean>
myCompletionPolicy类:
public class myCompletionPolicy extends SimpleCompletionPolicy {
private String recordCount;
public MapCpeBatchFileJobCompletionPolicy() {
setChunkSize(Integer.valueOf(recordCount));
}
public void setRecordCount(String recordCount) {
this.recordCount = recordCount;
}
}
有人可以告诉我怎样才能动态设置commit-interval值?感谢。