[英]Integrating spring batch framework to spring MVC framework
我想將Spring Batch框架集成到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']}]
回答你的問題
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.