Define an in-memory JobRepository

A few things here:

  1. If you have a DataSource configured in your ApplicationContext, by default Spring Batch will try to use it.
  2. In order to not use a DataSource when one is available within the ApplicationContext, you'll need to create your own BatchConfigurer. You can do that by extending the DefaultBatchConfigurer.
  3. Don't use the MapJobRepository except only for testing purposes. I has a number of issues (thread safety, etc) and is not recommended for production use. Use an in memory database like HSQLDB instead (you'll still need to create your own BatchConfigurer to do so).

With SpringBoot 2.x, the solution is simpler.

You have to extend the DefaultBatchConfigurer class like this:

@Component
public class NoPersistenceBatchConfigurer extends DefaultBatchConfigurer {
    @Override
    public void setDataSource(DataSource dataSource) {
    }
}

Without datasource, the framework automatically switches to use the MapJobRepository.