<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">


    <bean name="dataSourceB" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
        <property name="url" value="${mysql.slave.jdbcurl}"/>
        <property name="username" value="${mysql.slave.db.name}"/>
        <property name="password" value="${mysql.slave.db.password}"/>
        <property name="initialSize" value="10"/>
        <property name="maxActive" value="100"/>
        <property name="maxIdle" value="10"/>
        <property name="minIdle" value="0"/>
        <property name="maxWait" value="10000"/>
        <property name="testOnBorrow" value="false"/>
        <property name="testOnReturn" value="false"/>
        <property name="testWhileIdle" value="true"/>
        <property name="timeBetweenEvictionRunsMillis" value="60000"/>
        <property name="minEvictableIdleTimeMillis" value="25200000"/>
        <property name="removeAbandoned" value="true"/>
        <property name="removeAbandonedTimeout" value="1800"/>
        <property name="logAbandoned" value="true"/>
        <property name="filters" value="stat"/>
    </bean>


    <bean id="mainJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
          p:dataSource-ref="dataSourceB"/>

    <bean id="mainSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSourceB"/>
        <property name="mapperLocations">
            <list>
                <value>classpath*:mainOrm/slave/*.xml</value>
            </list>
        </property>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="mainSqlSessionFactory"></property>
        <property name="basePackage" value="com.lyms.platform.permission.dao.slave"/>
    </bean>


    <bean id="mainTransactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSourceB"/>
    </bean>

    <tx:annotation-driven transaction-manager="mainTransactionManager"/>

    <bean id="mainSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0" ref="mainSqlSessionFactory"/>
    </bean>
</beans>