简体   繁体   中英

How to pass data into spring batch ItemProcessor?

I have a CSV file that contains records of data (cases), for which I created a caseDTO object , however some of the properties of the caseDTO must be field from data included in the file name (every file must has a name with strict structure that contains some data).

What i want to achieve is to pass the data included in the file name to the item processor where i will append this data into every caseDTO before passing it to the item writer.

Does any one knows how to pass data to a step itemProcessor when I launch the job from the controller?

Thanks in advance.

the simplest solution is to set the dynamic parameters in the job parameters so the step's writer , processor , reader can have access to it . by injecting their values as following

@Value("#{jobParameters['fileName']}") public void setFileName(final String name) { //... }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM