What is the default TransactionManager implementation for a Spring Boot application?

Viewed 96

When Spring Data is added as a dependency to a Spring Boot project, which implementation of TransactionManager is available by default?

1 Answers

I had the same question. After digging through the Spring-Boot I found the following org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#transactionManager (Spring Boot version 2.6.4)

  @Bean
    @ConditionalOnMissingBean({TransactionManager.class})
    public PlatformTransactionManager transactionManager(ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
        JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManagerCustomizers.ifAvailable((customizers) -> {
            customizers.customize(transactionManager);
        });
        return transactionManager;
    }

So if you don't have a TransactionManager already defined, the default will be the JpaTransactionManager

Related