Skip to content

Improve code example in "Configuring and Running a Job" section #3888

Closed
@fmbenhassine

Description

@fmbenhassine

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();
		}
	};
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions