META-INF.sample.datasource-multi.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="multipleDataSource" class="com.github.dennisit.vplus.data.dsource.multi.MultipleDataSource"> <property name="targetDataSources"> <map key-type="java.lang.String"> <entry key="dbA" value-ref="dbB"/> <entry key="dbB" value-ref="dbB"/> </map> </property> <property name="defaultTargetDataSource" ref="dbA"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="multipleDataSource"/> </bean> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg ref="sqlSessionFactory"/> </bean> <bean id="multiMybatisTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="multipleDataSource"/> <tx:advice id="multiMybatisAdvice" transaction-manager="multiMybatisTransactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="insert*" propagation="REQUIRED"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="remove*" propagation="REQUIRED"/> <tx:method name="accept*" propagation="REQUIRED"/> <tx:method name="reject*" propagation="REQUIRED"/> <tx:method name="execute*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="recover*" propagation="REQUIRED"/> <tx:method name="sync*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <bean id="multiDataSourceAspect" class="com.github.dennisit.vplus.data.dsource.multi.MultipleDataSourceAspect"/> <aop:config> <aop:aspect ref="multiDataSourceAspect"> <aop:around method="doAround" pointcut="execution(public * com..wuyu..mapper.*.*(..))"/> </aop:aspect> </aop:config> </beans>