<?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一塊兒使用html