@EnableTransactionManagement in Spring Boot

后端 未结 6 1783
你的背包
你的背包 2020-12-07 16:58

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

6条回答
  •  鱼传尺愫
    2020-12-07 17:01

    According to > https://spring.io/guides/gs/managing-transactions/

    Spring Boot will detect spring-jdbc on the classpath and h2 and will create a DataSource and a JdbcTemplate for you automatically. Because such infrastructure is now available and you have no dedicated configuration, a DataSourceTransactionManager will also be created for you: this is the component that intercepts the @Transactional annotated method.

    You can also use spring-boot-starter-actuator to list your beans created in your context and you will find it

    bean": "transactionManager"

提交回复
热议问题