<?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"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
        ">
    <!-- 导入外部的properties文件-->
    <context:property-placeholder location="classpath*:jdbc.properties" ignore-unresolvable="true"/>
    
    <!-- c3p0连接池 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${c3p0.driverClassName}" />
        <property name="jdbcUrl" value="${c3p0.url}" />
        <property name="user" value="${c3p0.username}" />
        <property name="password" value="${c3p0.password}" />
        <property name="autoCommitOnClose" value="${c3p0.autoCommitOnClose}" />
        <property name="checkoutTimeout" value="${c3p0.checkoutTimeout}" />
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
        <property name="minPoolSize" value="${c3p0.minPoolSize}" />
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
        <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
        <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}" />
    </bean>-->

    <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="${jdbc.driver}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />

        <!-- 初始化连接大小 -->
        <property name="initialSize" value="${initialSize}" />
        <!-- 连接池最大使用连接数量 -->
        <property name="maxActive" value="${maxActive}" />

        <!-- 连接池最小空闲 -->
        <property name="minIdle" value="${minIdle}" />
        <!-- 获取连接最大等待时间 -->
        <property name="maxWait" value="${maxWait}" />
        <property name="poolPreparedStatements" value="${poolPreparedStatements}" />
        <property name="maxPoolPreparedStatementPerConnectionSize"
                  value="${maxPoolPreparedStatementPerConnectionSize}" />
        <!-- 用来检测有效sql -->
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />
        <property name="testWhileIdle" value="true" />
        <!-- 配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒 -->
        <property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
        <!-- 配置一个连接在池中最小生存的时间，单位是毫秒 -->
        <property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
        <!-- 打开removeAbandoned功能 -->
        <property name="removeAbandoned" value="true" />
        <!-- 1800秒，也就是30分钟 -->
        <property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" />
        <!-- 关闭abanded连接时输出错误日志 -->
        <property name="logAbandoned" value="true" />
        <!-- 监控数据库 -->
        <property name="filters" value="mergeStat" />
    </bean>
    
    <!-- ========================================针对myBatis的配置项============================== -->
    <!-- 配置sqlSessionFactory -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 实例化sqlSessionFactory时需要使用上述配置好的数据源以及SQL映射文件 -->
        <property name="dataSource" ref="dataSource" />
        <!-- 自动扫描me/gacl/mapping/目录下的所有SQL映射的xml文件, 省掉Configuration.xml里的手工配置
       value="classpath:me/gacl/mapping/*.xml"指的是classpath(类路径)下me.gacl.mapping包中的所有xml文件
       UserMapper.xml位于me.gacl.mapping包下，这样UserMapper.xml就可以被自动扫描
        -->
        <property name="typeAliasesPackage" value="com.ifish.bean"/>
        <property name="configLocation" value="classpath:mybatis-config.xml"></property>  
    </bean>
    <!-- 配置扫描器 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
        <property name="basePackage" value="com.ifish.mapper" />
       
    </bean>
    
    <!-- ========================================分隔线========================================= -->
    <!-- 配置Spring的事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    <!--     async配置 
    <task:annotation-driven executor="asyncExecutor"/>
    <task:executor id="asyncExecutor" pool-size="10-100" queue-capacity="5"/>-->
    <!-- 云信 -->
    <bean id="neteaseIM" class="com.ifish.netease.NeteaseIM"></bean>
    <!-- 短信推送 -->
    <bean id="smsNumSend" class="com.ifish.jpush.SmsNumSend"></bean>
</beans>
