diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java index 4386044baf72..72944ddf3f63 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java @@ -87,11 +87,13 @@ public DefaultDSLContext dslContext(org.jooq.Configuration configuration) { @Bean @ConditionalOnMissingBean(org.jooq.Configuration.class) public DefaultConfiguration jooqConfiguration(JooqProperties properties, ConnectionProvider connectionProvider, - DataSource dataSource, ObjectProvider executeListenerProviders, + DataSource dataSource, ObjectProvider transactionProvider, + ObjectProvider executeListenerProviders, ObjectProvider configurationCustomizers) { DefaultConfiguration configuration = new DefaultConfiguration(); configuration.set(properties.determineSqlDialect(dataSource)); configuration.set(connectionProvider); + transactionProvider.ifAvailable(configuration::set); configuration.set(executeListenerProviders.orderedStream().toArray(ExecuteListenerProvider[]::new)); configurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration)); return configuration; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java index c2b722ec9a0e..a85621810459 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfigurationTests.java @@ -113,6 +113,17 @@ void jooqWithDefaultConnectionProvider() { }); } + @Test + void jooqWithDefaultTransactionProvider() { + this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class, TxManagerConfiguration.class) + .run((context) -> { + DSLContext dsl = context.getBean(DSLContext.class); + TransactionProvider expectedTransactionProvider = context.getBean(TransactionProvider.class); + TransactionProvider transactionProvider = dsl.configuration().transactionProvider(); + assertThat(transactionProvider).isSameAs(expectedTransactionProvider); + }); + } + @Test void jooqWithDefaultExecuteListenerProvider() { this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class).run((context) -> {