| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.multiDataSource; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.ibatis.session.TransactionIsolationLevel; | 
|---|
|  |  |  | import org.apache.ibatis.transaction.Transaction; | 
|---|
|  |  |  | import org.mybatis.spring.transaction.SpringManagedTransactionFactory; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.sql.DataSource; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 在数据库连接会话启动后,由本事务工厂产生具体事务对象, | 
|---|
|  |  |  | * 由事务对象完成数据库表的事务操作。 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class MultiDataSourceTransactionFactory extends SpringManagedTransactionFactory { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Transaction newTransaction(DataSource multiDataSource, TransactionIsolationLevel level, boolean autoCommit) { | 
|---|
|  |  |  | Transaction transaction = new MultiDataSourceTransaction(multiDataSource, autoCommit); | 
|---|
|  |  |  | return transaction ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|