我正在研究spring Batch。我在作业执行上下文中将一些参数设置为JobListener beforeStep方法中的键值对。我想在我的bean定义中检索这些参数。但我得到例外。
我在作业定义中配置了此侦听器。
我的beforeJob()方法就像..
public void beforeJob(JobExecution jobExecution) {
// TODO Auto-generated method stub
System.out.println("Before Member Number Import Job");
log.info("Writing Failed File Header");
jobExecution.getExecutionContext().put("date", DateUtil.getDateString());
jobExecution.getExecutionContext().put("fileName", "dummy.txt");
writeHeader();
}
我用它来设置FlatFileReader bean的资源属性。
<property name="resource" value="file:#{jobExecutionContext['date']}" />
我得到以下异常。
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'jobExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:208)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97)
at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:82)
at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:1)
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)
... 27 more
请建议我如何解决这个问题。 在此先感谢