代碼通過使用Spring Batch的通過工作參數參數片段:無法在運行時
ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);
JobLauncher jobLauncher = context.getBean("jobLauncher", JobLauncher.class);
Job job = context.getBean("dadsdeviceJob",Job.class)
JobParameters jobParameters =
new JobParametersBuilder().addString("input.file.name", "cvs/input/fxe_dadsDevice.dat").toJobParameters();
try {
JobExecution execution = jobLauncher.run(job, jobParameters);
XML片段:
<bean id="dadsdeviceItemReader" scope="step" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="classpath:#{jobParameters['input.file.name']}"/>
<property name="lineMapper" ref="dadsdeviceLineMapper" />
<property name="strict" value="false" />
</bean>
Error: Input resource does not exist class path resource #{jobParameters['input.file.name']}.
誰能請盡力解決
http://stackoverflow.com/questions/13858593/access-job-parameter-in-itemreader-spring-batch-using-grails – hasnae