Skip to content

Commit 81a34fb

Browse files
author
Mattias Jiderhamn
committed
Allow setting transactionManager of DefaultBatchConfigurer
1 parent 164bf17 commit 81a34fb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
4949
@Autowired(required = false)
5050
public void setDataSource(DataSource dataSource) {
5151
this.dataSource = dataSource;
52-
this.transactionManager = new DataSourceTransactionManager(dataSource);
52+
}
53+
54+
@Autowired(required = false)
55+
public void setTransactionManager(PlatformTransactionManager transactionManager) {
56+
this.transactionManager = transactionManager;
5357
}
5458

5559
protected DefaultBatchConfigurer() {}
@@ -96,6 +100,10 @@ public void initialize() {
96100
jobExplorerFactory.afterPropertiesSet();
97101
this.jobExplorer = jobExplorerFactory.getObject();
98102
} else {
103+
if(this.transactionManager == null) {
104+
this.transactionManager = new DataSourceTransactionManager(dataSource);
105+
}
106+
99107
this.jobRepository = createJobRepository();
100108

101109
JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();

0 commit comments

Comments
 (0)