<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<aop:aspectj-autoproxy />
<context:annotation-config />
<context:component-scan base-package="org.fanlychie" />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<bean id="baseDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driver}" />
<property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
<property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
<property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
<property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
<property name="acquireRetryAttempts" value="${c3p0.acquireRetryAttempts}" />
<property name="acquireRetryDelay" value="${c3p0.acquireRetryDelay}" />
<property name="breakAfterAcquireFailure" value="${c3p0.breakAfterAcquireFailure}" />
<property name="autoCommitOnClose" value="${c3p0.autoCommitOnClose}" />
<property name="checkoutTimeout" value="${c3p0.checkoutTimeout}" />
<property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}" />
</bean>
<bean id="slaveDataSource" parent="baseDataSource">
<property name="jdbcUrl" value="${jdbc.url.slave}" />
<property name="user" value="${jdbc.username.slave}" />
<property name="password" value="${jdbc.password.slave}" />
</bean>
<bean id="masterDataSource" parent="baseDataSource">
<property name="jdbcUrl" value="${jdbc.url.master}" />
<property name="user" value="${jdbc.username.master}" />
<property name="password" value="${jdbc.password.master}" />
</bean>
<bean id="dataSource" class="org.fanlychie.core.MultipleDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="${jdbc.key.slave}" value-ref="slaveDataSource" />
<entry key="${jdbc.key.master}" value-ref="masterDataSource" />
</map>
</property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="org.fanlychie.entity" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.fanlychie.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<util:list id="useSlaveDataSourceMethodPrefix">
<value>select</value>
</util:list>
<util:list id="useMasterDataSourceMethodPrefix">
<value>insert</value>
<value>update</value>
<value>delete</value>
</util:list>
<bean class="org.fanlychie.core.MultipleDataSourceAspect" />
<bean class="org.fanlychie.core.MultipleDataSourceContext" />
</beans>