JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.34k stars 696 forks source link

Spring Boot Starter :: 2 Transaction Managers Found #869

Closed frederic-gendebien closed 4 years ago

frederic-gendebien commented 4 years ago

GIVEN: spring-boot.version: 2.2.4.RELEASE exposed.version: 0.23.1 WHEN: Application starts THEN: Application crashes: Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.transaction.TransactionManager' available: expected single matching bean but found 2: transactionManager,springTransactionManager

You have spring-boot-starter-data-jdbc which creates a spring TransactionManager through DataSourceTransactionManagerAutoConfiguration and you create another one through ExposedAutoConfiguration

It cannot work!

I think you should create an Exposed TransactionManager from the existing Spring DataSourceTransactionManager and just expose that interface not the spring one

Tapac commented 4 years ago

It can't created from DataSourceTransactionManager as SpringTransactionManager should override some methods of DSTM

I will exclude DataSourceTransactionManagerAutoConfiguration from auto-configuration via spring.factories. Hope that will help.

Declow0 commented 4 years ago

In servlet context i.e. WildFly i had same problem and excluding org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration helped me