<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-3.0.xsd
	http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        <!-- 开启注解 -->
	<context:annotation-config/>
	<context:component-scan base-package="com.msm.service.impl" />
	<!-- 加载系统属性文件 -->
	<bean id="propertyConfig" 	class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location" value="classpath:config.properties" />
	</bean>
	
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
        <!-- 
        <property name="driverClass" value="${jdbc_driver}"></property>
        <property name="jdbcUrl" value="${jdbc_url}"></property>
        <property name="user" value="${jdbc_username}"></property>
        <property name="password" value="${jdbc_password}"></property>
         -->
        <property name="url" value="${jdbc_url}" />
		<property name="username" value="${jdbc_username}" />
		<property name="password" value="${jdbc_password}" />
        
        <!-- 初始化连接大小 -->
		<property name="initialSize" value="0" />
		<!-- 连接池最大使用连接数量 -->
		<property name="maxActive" value="20" />
		<!-- 连接池最大空闲 -->
		<property name="maxIdle" value="20" />
		<!-- 连接池最小空闲 -->
		<property name="minIdle" value="0" />
		<!-- 获取连接最大等待时间 -->
		<property name="maxWait" value="60000" />

		<property name="validationQuery" value="${validationQuery}" />
		<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" />

		<!-- 打开removeAbandoned功能 -->
		<property name="removeAbandoned" value="true" />
		<!-- 1800秒，也就是30分钟 -->
		<property name="removeAbandonedTimeout" value="1800" />
		<!-- 关闭abanded连接时输出错误日志 -->
		<property name="logAbandoned" value="true" />

		<!-- 监控数据库 -->
		<!-- <property name="filters" value="stat" /> -->
		<property name="filters" value="mergeStat" />
		
    </bean>
 	<!-- 使用spring的会话管理 -->
 	<!-- 
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="/WEB-INF/Configration.xml" />
    </bean>
     -->
    
    <!-- myBatis文件 -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
		<property name="mapperLocations" value="classpath:mybatis/*.xml" />
	</bean>
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.msm.mapper" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
	</bean>
	
	<!-- 事务管理器 -->  
	<bean id="txManager"  
	    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
	        <property name="dataSource" ref="dataSource" />  
	</bean>  
	  
	<!-- 事务注解驱动，标注@Transactional的类和方法将具有事务性 -->  
	<tx:annotation-driven transaction-manager="txManager" ></tx:annotation-driven>
	<!-- 
    <bean id="mongoDbFactory" class="com.supermap.spmd.core.MongoDbFactory">
    	<constructor-arg name="ip" value="${mongo_ip}"></constructor-arg>
    	<constructor-arg name="port" value="${mongo_port}"></constructor-arg>
    	<constructor-arg name="username" value=""></constructor-arg>
    	<constructor-arg name="password" value=""></constructor-arg>
    </bean>
     -->
    <!-- 
	 <bean id="logAspect" class="com.supermap.spmd.tool.LogAspect"></bean>
    <aop:aspectj-autoproxy proxy-target-class="true"/>
     -->
</beans>