etig
etig

Reputation: 523

Disable transaction manager in Spring Boot application

How to disable transaction manager in Spring Boot application?

I have this exception :

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined

Because of @Transactional annotations (I use these annotations in an other app, so I can't remove, but there is a way to ignore it? By disable transaction manager?).

Upvotes: 5

Views: 15587

Answers (1)

Dave Syer
Dave Syer

Reputation: 58094

I guess you have three choices:

  1. remove the annotation

  2. supply a transaction manager

  3. exclude the configuration class that adds @EnableTransactionManagement

In a Spring Boot app you only get @EnableTransactionManagement if you are using JDBC or JPA, so really there should be a transaction manager already. The only reason I can see for one not being there is you have spring-jdbc on the classpath but no database. If you have spring-tx and spring-jdbc on your classpath already (which seems to be the case) you can just add an in-memory database (e.g. h2) to get a transaction manager. That seems like the best solution to me. But you could also exclude DataSourceTransactionManagerAutoConfiguration in your @EnableAutoConfiguration.

Upvotes: 5

Related Questions