Interface TransactionManagementConfigurer
Configuration classes annotated with @EnableTransactionManagement that wish to
 (or need to) explicitly specify the default PlatformTransactionManager bean
 (or ReactiveTransactionManager bean) to be used for annotation-driven
 transaction management, as opposed to the default approach of a by-type lookup.
 One reason this might be necessary is if there are two PlatformTransactionManager
 beans (or two ReactiveTransactionManager beans) present in the container.
 See @EnableTransactionManagement for general examples and context;
 see annotationDrivenTransactionManager() for detailed instructions.
 
NOTE: A TransactionManagementConfigurer will get initialized early.
 Do not inject common dependencies into autowired fields directly; instead, consider
 declaring a lazy ObjectProvider for those.
 
Note that in by-type lookup disambiguation cases, an alternative approach to
 implementing this interface is to simply mark one of the offending
 PlatformTransactionManager @Bean methods (or
 ReactiveTransactionManager @Bean methods) as
 @Primary.
 This is even generally preferred since it doesn't lead to early initialization
 of the TransactionManager bean.
- Since:
- 3.1
- Author:
- Chris Beams
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionReturn the default transaction manager bean to use for annotation-driven database transaction management, i.e.
- 
Method Details- 
annotationDrivenTransactionManagerTransactionManager annotationDrivenTransactionManager()Return the default transaction manager bean to use for annotation-driven database transaction management, i.e. when processing@Transactionalmethods.There are two basic approaches to implementing this method: 1. Implement the method and annotate it withIn this case, the implementing@Bean@Configurationclass implements this method, marks it with@Bean, and configures and returns the transaction manager directly within the method body:@Bean @Override public PlatformTransactionManager annotationDrivenTransactionManager() { return new DataSourceTransactionManager(dataSource()); }2. Implement the method without@Beanand delegate to another existing@Beanmethod@Bean public PlatformTransactionManager txManager() { return new DataSourceTransactionManager(dataSource()); } @Override public PlatformTransactionManager annotationDrivenTransactionManager() { return txManager(); // reference the existingIf taking approach #2, be sure that only one of the methods is marked with@Beanmethod above }@Bean!In either scenario #1 or #2, it is important that the PlatformTransactionManagerinstance is managed as a Spring bean within the container since mostPlatformTransactionManagerimplementations take advantage of Spring lifecycle callbacks such asInitializingBeanandBeanFactoryAware. Note that the same guidelines apply toReactiveTransactionManagerbeans.- Returns:
- a PlatformTransactionManagerorReactiveTransactionManagerimplementation
 
 
-