I\'m having a bit of trouble with Spring Batch. I am in this situation: I have to analyze the data inside a file and insert everything in a database (Oracle). The problem I
This is how I've solved it in the past. This was non-boot and old Spring, but it might still work with whatever environment you're in. By default the setDataSource()
will be injected with your Oracle ds, but if you prevent it from being injected, Spring Batch will just store those details in memory.
If you want a different datasource to be used (i.e. if you want the batch metadata to still be persisted), you could probably use @Qualifier
to specify a different datasource bean and call super.setDataSource(dataSource);
. Probably other ways to do it too, haven't touched this code in a few years.
@Configuration
@EnableBatchProcessing
public class BatchConfig extends DefaultBatchConfigurer {
@Override
@Autowired
public void setDataSource(DataSource dataSource) {
// If we don't provide a datasource, an in-memory map will be used.
}
}