<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
		http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
		http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd">
	
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="typeAliasesPackage" value="classpath*:/com.rtrh.core.plugins,com.rtrh.core.plugins,com.rtrh.demo.modules" />
	<!-- 	<property name="configLocation" value="classpath:mybatisMsSqlConfig.xml" /> -->
		<property name="mapperLocations" >
			<list>
              <value>classpath*:/com/rtrh/core/plugins/**/mapper/*Mapper.xml</value>
              <value>classpath*:/com/rtrh/projects/modules/**/*Mapper.xml</value>
			</list>
		</property>
		<property name="plugins">
		    <list>
		      <bean class="com.github.pagehelper.PageHelper">
		        <property name="properties">
		          <value>
		            dialect=mysql
		            reasonable=true
		          </value>
		        </property>
		      </bean>
		    </list>
		  </property>
	</bean>

	<bean id="secondarySqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="typeAliasesPackage" value="classpath*:/com/rtrh/core/plugins,com.rtrh.core.plugins,com.rtrh.demo.modules" />
		<property name="mapperLocations">
			<list>
				<value>classpath*:/com/rtrh/core/plugins/**/mapper/*Mapper.xml</value>
				<value>classpath*:/com/rtrh/projects/modules/**/*Mapper.xml</value>
			</list>
		</property>
		<property name="plugins">
			<list>
				<bean class="com.github.pagehelper.PageHelper">
					<property name="properties">
						<value>
							dialect=mysql
							reasonable=true
						</value>
					</property>
				</bean>
			</list>
		</property>
	</bean>
	
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="annotationClass" value="com.rtrh.core.repository.mybatis.MyBatisRepository" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
		<property name="basePackage" value="com.rtrh.core.plugins.**.mapper,com.rtrh.**.modules.**.mapper" />
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="annotationClass" value="com.rtrh.core.repository.mybatis.MyBatisRepository" />
		<property name="sqlSessionFactoryBeanName" value="secondarySqlSessionFactory" />
		<property name="basePackage" value="com.rtrh.core.plugins.**.mapper,com.rtrh.**.modules.**.mapper" />
	</bean>


	<!-- 配置事务 -->  
	<bean id="txManager_mybatis"  
	        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
	    <property name="dataSource" ref="poolDataSource" />  
	</bean>
	<bean id="txManager_secondary"
		  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="secondaryDataSource" />
	</bean>

	<!-- 配置基于注解的事物aop -->  
	<tx:annotation-driven transaction-manager="txManager_mybatis" proxy-target-class="true"/>
	<tx:annotation-driven transaction-manager="txManager_secondary" proxy-target-class="true"/>

</beans>