Search code examples
configurationspring-batchdatasourcejava-17

spring batch 5 without datasource


I'm trying to migrate my spring batch from v4 to v5, but this batch doesn't use a database. The problem is when i'm trying to run the batch with the news changes, i got this error : JobRepository is mandatory

Is it now mandatory to have a datasource on spring batch 5 ? Or can we avoid it like old version by declaring the override method "setDatasource" ?

Thanks a lot guys.

I tried to exclude DataSourceAutoConfiguration on the application and i searched how to disable it on application.properties but i found nothing.


Solution

  • The JobRepository has always been mandatory in Spring Batch. What has changed between v4 and v5 is that the Map-based implementation (that was used by default when there is no datasource defined) was removed.

    Therefore, you either have to define a datasource (could be an embedded one) and use the JDBC-based JobRepository, or provide a custom JobRepository implementation according to your needs.