在运行时动态选择弹簧批量阅读器

在运行时动态选择弹簧批量阅读器

本文介绍了在运行时动态选择弹簧批量阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个弹出批处理作业,可以将各种银行对帐单转换为我的应用程序。每种银行对账单类型都有一个不同的读者,所有这些只有一个作者。这项工作非常简单 - 阅读,处理和写作:I have a spring-batch job that converts various bank statements into my app. There is a different reader for each bank statement type and only one writer for all of them. The job is very simple - read, process and write:<batch:job id="importer" restartable="true"> <batch:step id="import"> <batch:tasklet> <batch:chunk reader="reader" writer="writer" processor="processor" commit-interval="10" /> </batch:tasklet> </batch:step></batch:job>现在,我希望最终用户提供一个声明文件以及银行信息,然后选择运行时相应的弹簧批处理读取器,以运行此作业。理想情况下,如果我能够在第一步中预读并尝试首先猜测银行表单语句格式,那将是很好的。但我离题了。Now, I would like the end user to provide a statement file as well as bank information and then choose a corresponding spring-batch reader at runtime for this job to run. Ideally it would be great if I could read-ahead in a first step and tried to "guess" the bank form statement format first. But I digress.在运行之前是否可以将读卡器注入作业?或者有更好的方法来实现我的目标吗?Is it possible to inject a reader into a job prior to running it? Or is there a better way to achieve my goal?推荐答案您可以从输入参数/或propeties文件设置阅读器:You can set the reader from an input parameter/or a propeties file:<batch:chunk reader="#{jobParameters['reader.beanId']}" writer="writer" processor="processor" commit-interval="10" />您还可以考虑作业和步骤属性的后期绑定,这里是spring-batch的链接步长范围Also you could consider late binding of job and step attributes, here is the link from spring-batch step-scope 这篇关于在运行时动态选择弹簧批量阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-06 02:57