Closed
Description
The default constrcutor of DefaultBatchConfigurer
is protected and can't be used in a code example like the following:
@Bean
public BatchConfigurer batchConfigurer() {
return new DefaultBatchConfigurer();
}
The code example that shows how to provide a custom transaction manager via a BatchConfigurer
in the Configuring and Running a Job uses the default constructor of DefaultBatchConfigurer
. While this is correct as the snippet uses an anonymous extension class, it does not show which datasource is being used as it is implicitly autowired. It is better to use the constructor that takes a DataSource
which is more explicit about the datasource being used:
@Bean
--public BatchConfigurer batchConfigurer() {
++public BatchConfigurer batchConfigurer(DataSource dataSource) {
-- return new DefaultBatchConfigurer() {
++ return new DefaultBatchConfigurer(dataSource) {
@Override
public PlatformTransactionManager getTransactionManager() {
return new MyTransactionManager();
}
};
}