Is @EnableTransactionManagement
required in Spring Boot?
I did some research. Some folks say you don\'t need it, as Spring Boot has it already enabled, others s
Probably you're also using Spring Data. Calls on Spring Data repositories are by default surrounded by a transaction, even without @EnableTransactionManagement
. If Spring Data finds an existing transaction, the existing transaction will be re-used, otherwise a new transaction is created.
@Transactional
annotations within your own code, however, are only evaluated when you have @EnableTransactionManagement
activated (or configured transaction handling some other way).
You can easily trace transaction behavior by adding the following property to your application.properties
:
logging.level.org.springframework.transaction.interceptor=TRACE
(see Showing a Spring transaction in log)