我想将spring批处理框架集成到spring MVC框架中,但是会出现以下错误。
发布代码段以获得更多说明。
JobParametersBuilder jpBuilder = new JobParametersBuilder().addString("inputfilename", "cvs/input/fxe_dadsDevice.dat");
jpBuilder.addString("output.file.name", "files/output/"+System.currentTimeMillis()+"_test.txt");
jobLauncher.run(job, jpBuilder.toJobParameters());
XML片段:
<bean class="org.springframework.batch.core.scope.StepScope" />
<bean id="dadsdeviceItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="resource" value=”#{jobParameters['input.file.name']}"/>
<property name="lineMapper" ref="dadsdeviceLineMapper" />
<property name="strict" value="false" />
</bean>
错误:
FlatFileItemReader:253 - Input resource does not exist URL [file:#{jobParameters['input.file.name']}]
答案 0 :(得分:0)
回答您的问题
1)请像这样使用
<bean id="inputFile" class="org.springframework.batch.core.resource.StepExecutionResourceProxy">
<property name="filePattern" value="file://%file.name%"/>
</bean>
<bean id="dadsdeviceItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" ref="inputFile" />
</bean>