spring-batch

Spring batch Job read from multiple sources

a 夏天 提交于 2019-11-26 09:45:37
问题 How can I read items from multiples databases? I already know that is possible from files. the following example works for read from multiples files ... <job id=\"readMultiFileJob\" xmlns=\"http://www.springframework.org/schema/batch\"> <step id=\"step1\"> <tasklet> <chunk reader=\"multiResourceReader\" writer=\"flatFileItemWriter\" commit-interval=\"1\" /> </tasklet> </step> </job> ... <bean id=\"multiResourceReader\" class=\" org.springframework.batch.item.file.MultiResourceItemReader\">

Use of multiple DataSources in Spring Batch

99封情书 提交于 2019-11-26 04:49:21
问题 I am trying to configure a couple of datasources within Spring Batch. On startup, Spring Batch is throwing the following exception: To use the default BatchConfigurer the context must contain no more thanone DataSource, found 2 Snippet from Batch Configuration @Configuration @EnableBatchProcessing public class BatchJobConfiguration { @Primary @Bean(name = \"baseDatasource\") public DataSource dataSource() { // first datasource definition here } @Bean(name = \"secondaryDataSource\") public

How can we share data between the different steps of a Job in Spring Batch?

主宰稳场 提交于 2019-11-26 02:54:55
问题 Digging into Spring Batch, I\'d like to know as to How can we share data between the different steps of a Job? Can we use JobRepository for this? If yes, how can we do that? Is there any other way of doing/achieving the same? 回答1: the job repository is used indirectly for passing data between steps (Jean-Philippe is right that the best way to do that is to put data into the StepExecutionContext and then use the verbosely named ExecutionContextPromotionListener to promote the step execution