Spring Batch 6 introduces support for "resource less" infrastructure. With this mode, a database is not required and this could be helpful for those who do not need it and are currently forced to add an in-memory database for that purpose.

Spring Batch 6 is similar to Spring Session in that regards with a EnableJdbcJobRepository that can be used by the user to opt-in for database storage.

The biggest problem that I can see now is that Spring Boot extends from the base configuration to customize features and for Spring Session we "just" import the configuration class. With JdbcDefaultBatchConfiguration extending from DefaultBatchConfiguration, it makes such extension complicated as we'd have to replicate the overrides in two classes.

cc @fmbenhassine

Comment From: fmbenhassine

Thank you for considering this! I believe Spring Boot should auto-configure a resource less infrastructure by default, and switches to jdbc or mongodb based on classpath scanning (spring-jdbc / spring-boot-starter-data-mongodb) or a property like spring.batch.job.repository=[resourceless,jdbc,mongodb]. This means starting a new project from start.spring.io with only batch as dependency would work OOTB, while it currently does not as it requires an embedded database.

The biggest problem that I can see now is that Spring Boot extends from the base configuration to customize features and for Spring Session we "just" import the configuration class. With JdbcDefaultBatchConfiguration extending from DefaultBatchConfiguration, it makes such extension complicated as we'd have to replicate the overrides in two classes.

What about making SpringBootBatchConfiguration extend DefaultBatchConfiguration for the default resource less infrastructure, and adding two new classes SpringBootJdbcBatchConfiguration and SpringBootMongoBatchConfiguration that would be conditional?

Comment From: wilkinsona

I believe Spring Boot should auto-configure a resource less infrastructure by default, and switches to jdbc or mongodb based on classpath scanning (spring-jdbc / spring-boot-starter-data-mongodb)

I'm not sure that the classpath will provide a strong enough signal. For example, you may be happy for Batch to use its resource-less infrastructure but you want to use JDBC elsewhere in your app. Similarly, you may be using both JDBC and MongoDB in your app but you want Batch to use one in particular.

or a property like spring.batch.job.repository=[resourceless,jdbc,mongodb]

A property would provide a much stronger signal.

Another option is multiple spring-boot-batch-* modules, but this may be overkill. spring-boot-batch could be for the resource-less case with new spring-boot-batch-jdbc and spring-boot-batch-mongodb handling the two different repositories.

Comment From: fmbenhassine

I agree, classpath scanning won't work. Multiple modules is a clean option, but might be an overkill indeed. So I believe a property is a good middle ground option.

What about using spring.batch.job.repository.type=[resourceless,jdbc,mongodb] and move jdbc properties and the new mongodb properties (those will be discussed in a separate issue) under spring.batch.job.repository.jdbc.* and spring.batch.job.repository.mongodb.* ?