Spring - Is it possible to use multiple transaction managers in the same application?

后端 未结 2 1884
不知归路
不知归路 2020-11-28 03:52

I\'m new to Spring and I\'m wondering if its possible to use numerous transaction managers in the same application?

I have two data access layers - one for both of t

2条回答
  •  自闭症患者
    2020-11-28 04:44

    Where you use a @Transactional annotation, you can specify the transaction manager to use by adding an attribute set to a bean name or qualifier. For example, if your application context defines multiple transaction managers with qualifiers:

    
        
        
    
    
    
        
        
    
    

    You can use the qualifier to specify the transaction manager to use:

    public class TransactionalService {
    
        @Transactional("account")
        public void setSomethingInAccount() { ... }
    
        @Transactional("businessData")
        public void doSomethingInBusinessData() { ... }
    }
    

提交回复
热议问题