I'm working on a Spring Batch project where I need to use two different data sources. I'm planning to use RepositoryItemReader and RepositoryItemWriter for reading and writing to these databases. However, I couldn't find any documentation on how to configure Spring Batch for this specific scenario.
Additionally, when I added JPA configuration, Spring Batch seems to default to using MySQL for its internal operations. How can I configure Spring Batch to work with two data sources and prevent this default behavior when using JPA?
If you use
@EnableBatchProcessing, you can configure the datasource you want for theJobRepositoryby setting thedataSourceRefattribute. For example:The equivalent to that with the programmatic approach is by overriding
DefaultBatchConfiguration#getDataSource().The same datasource can then be set on the item reader and writer.