<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
	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-3.1.xsd
                           http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
                           http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
                           http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">

	<!-- 采用注释的方式配置bean -->
	<context:annotation-config />
	<bean id="configProperties"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="locations">
			<list>
				<value>classpath:database.properties</value>
			</list>
		</property>
	</bean>
	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
		<property name="properties" ref="configProperties" />
	</bean>
	
	
	<!-- 配置数据源  A-->
	<bean name="dataSourceA"  class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
		<property name="url" value="${mysql.db.jdbcurl}" />
		<property name="username" value="${mysql.db.username}" />
		<property name="password" value="${mysql.db.password}" />

		<!-- 初始化连接大小 -->
		<property name="initialSize" value="${mysql.initialpoolsize}" />
		<!-- 连接池最大使用连接数量 -->
		<property name="maxActive" value="${mysql.maxactive}" />
		<!-- 连接池最大空闲 -->
		<property name="maxIdle" value="${mysql.maxIdle}" />
		<!-- 连接池最小空闲 -->
		<property name="minIdle" value="${mysql.minpoolsize}" />
		<!-- 获取连接最大等待时间 -->
		<property name="maxWait" value="${mysql.maxwait}" />

		<!-- <property name="poolP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          reparedStatements" value="true" /> <property name="maxPoolPreparedStatementPerConnectionSize" value="33" /> -->
		<property name="validationQuery" value="${mysql.validationquery}" />
		<property name="testOnBorrow" value="true" />
		<property name="testOnReturn" value="false" />
		<property name="testWhileIdle" value="true" />
		<!-- 配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="60000" />
		<!-- 配置一个连接在池中最小生存的时间，单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="25200000" />
		<!-- 打开removeAbandoned功能 -->
		<property name="removeAbandoned" value="true" />
		<!-- 1800秒，也就是30分钟 -->
		<property name="removeAbandonedTimeout" value="1800" />
		<!-- 关闭abanded连接时输出错误日志 -->
		<property name="logAbandoned" value="true" />
		
		<!-- 打开PSCache，并且指定每个连接上PSCache的大小 -->
	    <property name="poolPreparedStatements" value="true" />
	    <property name="maxPoolPreparedStatementPerConnectionSize" value="1000" />
		
		<!-- 监控数据库 -->
		 <property name="filters" value="stat" /> 
	</bean>
	<!-- 配置要扫描的包 -->
	<context:component-scan base-package="com.lyms.platform.data" />

	<!-- DataSource configuration 妈咪baby主数据库 -->
	<bean id="mmbbDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${earlydata.driver}" />
		<property name="jdbcUrl" value="${earlydata.jdbcurl}" />
		<property name="user" value="${earlydata.username}" />
		<property name="password" value="${earlydata.password}" />
		<property name="maxPoolSize" value="${earlydata.maxpoolsize}" />
		<property name="initialPoolSize" value="${earlydata.initialpoolsize}" />
		<property name="maxIdleTime" value="7200"></property>
		<property name="acquireRetryDelay" value="1000"></property>
		<property name="breakAfterAcquireFailure" value="false"></property>
		<property name="acquireRetryAttempts" value="3" />
		<property name="minPoolSize" value="${earlydata.minpoolsize}" />
	</bean>

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

	<bean id="mmbbSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="mmbbDataSource" />
		<property name="mapperLocations">
			<list>
				<value>classpath*:earlyOrm/*.xml</value>
			</list>
		</property>
	</bean>

	<!-- manage transaction -->
	<bean id="mmbbTransactionManager"
		  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="mmbbDataSource" />
	</bean>

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

	<!-- Mabatis Data Layer -->
	<bean id="mmbbSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
		<constructor-arg index="0" ref="mmbbSqlSessionFactory" />
	</bean>

	<!-- all class in the back-package are auto loaded as a mapper -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="sqlSessionFactoryBeanName" value="mmbbSqlSessionFactory"></property>
		<property name="basePackage" value="com.lymsh.mommybaby.earlydata.dao" />
	</bean>

	<import resource="applicationContext-cxf.xml" />
</beans>