代码段:
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']}.
任何人都可以尝试解决它
答案 0 :(得分:0)
我没有看到其他配置详情,但您可以这样做
JobLauncher jobLauncher = context.getBean("jobLauncher", JobLauncher.class);
Job job = context.getBean("dadsdeviceJob",Job.class)
// get your bean and inject your resources like this before
FlatFileItemReader reader = (FlatFileItemReader) context.getBean("dadsdeviceItemReader");
//
reader.setResource(new ClassPathResource(path));
// or you can give FSR path also like this
reader.setResource(new FileSystemResource(path));