0
<beans>
<batch:job id="job1" restartable="false">
<batch:step id="step1" next="step2">
<batch:tasklet>
<batch:chunk reader="readerA" writer="writerA" commit-interval="1" />
</batch:tasklet>
</batch:step>
<batch:step id="step2">
<batch:tasklet ref="tasklet1"/>
</batch:step>
<batch:listeners>
<batch:listener ref="listenerA" />
</batch:listeners>
</batch:job>
<bean id="listenerA" class="com.example.ListenerA" scope="step">
<property name="archiveDate" value="#{jobParameters['jobRunDate']}" />
</bean>
</beans>
为什么上面给我以下错误:Spring批处理:如何在步骤侦听器中使用占位符?
java.lang.IllegalStateException: No context available while replacing placeholders.
什么是解决这个问题的最好方法?
不幸的是,这是一个工作监听者。 – 2011-04-07 17:51:08
作业执行侦听器包含以下方法:void beforeJob(JobExecution执行)和void afterJob(JobExecution执行)void。正如我在我的回答中所说的,如果它是一个作业侦听器,则不需要占位符 - 在beforeJob中只需使用execution.getJobInstance()。getJobParameters()。getDate(“jobRunDate”); (假设它是一个日期,如果没有的话,使用适当的getter作为值)。 – MetroidFan2002 2011-04-10 23:12:12
这不似乎违反了通过xml进行配置的想法吗? – 2011-05-19 23:34:04