Prefer JdbcTransactionManager over DataSourceTransactionManager

Spring 5.3 introduced the JdbcTransactionManager with exception
translation on commit and rollback. This commit updates the
auto-configuration to use this implementation rather than
DataSourceTransactionManager.

See gh-23672
pull/23628/head
Marten Deinum 4 years ago committed by Stephane Nicoll
parent 70ed7784a6
commit f9d50ee86a

@ -30,12 +30,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.transaction.TransactionManager;
/**
* {@link EnableAutoConfiguration Auto-configuration} for
* {@link DataSourceTransactionManager}.
* {@link EnableAutoConfiguration Auto-configuration} for {@link JdbcTransactionManager}.
*
* @author Dave Syer
* @author Stephane Nicoll
@ -55,9 +54,9 @@ public class DataSourceTransactionManagerAutoConfiguration {
@Bean
@ConditionalOnMissingBean(TransactionManager.class)
DataSourceTransactionManager transactionManager(DataSource dataSource,
JdbcTransactionManager transactionManager(DataSource dataSource,
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
JdbcTransactionManager transactionManager = new JdbcTransactionManager(dataSource);
transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(transactionManager));
return transactionManager;
}

Loading…
Cancel
Save