applicationContext-datasource-mail.xml 2.68 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
  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-4.3.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
  <!-- DruidDataSource数据源配置) -->
  <!-- See: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_DruidDataSource%E5%8F%82%E8%80%83%E9%85%8D%E7%BD%AE -->
  <bean id="dataSourceMail" class="com.alibaba.druid.pool.DruidDataSource"
    init-method="init" destroy-method="close">
    <!-- 基本属性 url、user、password -->
    <property name="url" value="${mail_jdbc_url}" />
    <property name="username" value="${mail_jdbc_user}" />
    <property name="password" value="${mail_jdbc_password}" />

    <!-- 配置初始化大小、最小、最大 -->
    <property name="initialSize" value="${atms.config.druid.initialSize:0}" />
    <property name="minIdle" value="${atms.config.druid.minIdle:1}" />
    <property name="maxActive" value="${atms.config.druid.maxActive:20}" />

    <!-- 配置获取连接等待超时的时间 -->
    <property name="maxWait" value="${atms.config.druid.maxWait:60000}" />

    <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
    <property name="timeBetweenEvictionRunsMillis" value="${atms.config.druid.timeBetweenEvictionRunsMillis:60000}" />

    <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
    <property name="minEvictableIdleTimeMillis" value="${atms.config.druid.minEvictableIdleTimeMillis:300000}" />

    <property name="validationQuery" value="${jdbc_validationQuery:select 1 from INFORMATION_SCHEMA.SYSTEM_USERS}" />
    <property name="testWhileIdle" value="true" />
    <property name="testOnBorrow" value="false" />
    <property name="testOnReturn" value="false" />

    <!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
    <property name="poolPreparedStatements" value="true" />
    <property name="maxPoolPreparedStatementPerConnectionSize"
      value="20" />

    <!-- 配置监控统计拦截的filters -->
    <property name="filters" value="stat" />
  </bean>
</beans>