itemReader で JobParameters にアクセスしようとしています。Spring ユーザー ガイドの「ジョブとステップ属性のレイト バインディング」に従いましたが、機能しません。
これが私の構成です:Spring-batch 2.1.8 Spring-core 3.0.5
<bean id="ipcFileReader" scope="step" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="#{jobParameters['filename']}"/>
<property name="lineMapper" ref="lineMapper"/>
<property name="comments" value="#"/>
</bean>
私のテストクラス:
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class,StepScopeTestExecutionListener.class})
@ContextConfiguration
public class IpcFileReaderTest {
@Autowired
private ItemReader<Client> ipcFileReader;
public StepExecution getStepExecution(){
StepExecution execution = MetaDataInstanceFactory.createStepExecution();
execution.getExecutionContext().putString("filename",System.getProperty("user.dir") + "/src/test/resources/OMC_File/OMC_Test_1.csv");
return execution;
@Test
public void testReader() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception{
Assert.assertNotNull(ipcFileReader.read());
}
}
しかし、私はいつもこのエラーを受け取りました:
Error creating bean with name 'lazyBindingProxy.lazyBindingProxy.ipcFileReader#execution#1234' defined in class path resource [applicationContext-Ipc.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Cannot bind to placeholder: jobParameters['filename']
何か案は ?
どうも