<?xml version="1.0" encoding="UTF-8"?>
<!--suppress SpringFacetInspection -->
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<bean id="dataSourceTemplate" class="com.alibaba.druid.pool.DruidDataSource" abstract="true" init-method="init"
destroy-method="close">
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="3"/>
<property name="minIdle" value="10"/>
<property name="maxActive" value="20"/>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="phyTimeoutMillis" value="1500000" />
<property name="validationQuery" value="SELECT 'x'"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<!-- 打开removeAbandoned功能 -->
<property name="removeAbandoned" value="true"/>
<!-- 1800秒,也就是30分钟 -->
<property name="removeAbandonedTimeout" value="1800"/>
<!-- 关闭abanded连接时输出错误日志 -->
<property name="logAbandoned" value="true"/>
<property name="proxyFilters">
<list>
<ref bean="logFilter" />
<ref bean="statFilter" />
</list>
</property>
<property name="filters" value="stat,config,wall"/>
<property name="connectionProperties"
value="config.decrypt=true;druid.log.conn=false;druid.log.stmt=false;druid.log.rs=false;druid.log.stmt.executableSql=true;"/>
</bean>
<!-- 开启慢查询日志 -->
<bean id="statFilter" class="com.alibaba.druid.filter.stat.StatFilter">
<property name="slowSqlMillis" value="200" />
<property name="logSlowSql" value="true" />
<property name="mergeSql" value="true" />
</bean>
<bean id="logFilter" class="com.alibaba.druid.filter.logging.Slf4jLogFilter" />
</beans>
配合logback一起使用