The spring version must be later than 3.x, because the @ transcation annotation in 2.x does not support multiple data sources.
After 3. X, we can give pointers by specifying the name. This annotation uses the Transaction Manager. If this parameter is not specified, the transaction manager named "transationmanager" is used by default.
Not much nonsense. Example:
<TX: annotation-driven/> <bean id = "transactionmanager1" class = "org. springframework. JDBC. datasourcetransactionmanager ">... <qualifier value = "A"/> </bean> <bean id = "transactionmanager2" class = "org. springframework. JDBC. datasourcetransactionmanager ">... <qualifier value = "B"/> </bean>
We use qualifier to set a qualified name for two transactionmanagers, so we only need to attach the annotation.
@ Transactional ("A") Public void dosomething (string name) {...} @ transactional ("B") Public void dosomething (){...}