我有一个春季批处理工作,需要读取平面文件并进行处理,源平面文件具有主体和页脚。对于正文部分,我需要从对象的平面文件中读取一行并进行处理,但是对于页脚,我仅需要验证信息,因此不需要处理器。我收到一个错误,指出对象无法强制转换,我理解该错误,这是因为页脚未读入与正文相同的对象,但找不到解决方案。 这是我的工作定义:
<batch:job>
<batch:step id="readDetailStep">
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk reader="flatFileItemReader" processor="processor"
writer="writer" commit-interval="1000" skip-limit="1">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="detailLineTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
</bean>
<bean id="footerLineTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
</bean>
<bean id="detailFieldSetMapper"
class="ben.MyMapper">
</bean>
<bean id="footerFieldSetMapper"
class="ben.FooterMapper" />
<!-- composite writer -->
<bean id="writer" class="org.springframework.batch.item.support.CompositeItemWriter">
<property name="delegates">
<list>
<bean id="writer1" class="ben.MyWriter" />
</list>
</property>
</bean>
<bean id="processor" class="ben.MyProcessor" />