<!-- master数据源 --> <bean id="masterDataSource" class="com.alibaba.druid.pool.DruidDataSource"> <!-- 基本属性 url、user、password --> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialSize" value="${jdbc.initialSize}" /> <property name="minIdle" value="${jdbc.minIdle}" /> <property name="maxActive" value="${jdbc.maxActive}" /> <property name="maxWait" value="${jdbc.maxWait}" /> <!-- 超过时间限制是否回收 --> <property name="removeAbandoned" value="${jdbc.removeAbandoned}" /> <!-- 超过时间限制多长; --> <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}" /> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}" /> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}" /> <!-- 用来检测连接是否有效的sql,要求是一个查询语句--> <property name="validationQuery" value="${jdbc.validationQuery}" /> <!-- 申请连接的时候检测 --> <property name="testWhileIdle" value="${jdbc.testWhileIdle}" /> <!-- 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 --> <property name="testOnBorrow" value="${jdbc.testOnBorrow}" /> <!-- 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 --> <property name="testOnReturn" value="${jdbc.testOnReturn}" /> </bean> <!-- slave数据源 --> <bean id="slaveDataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${slave.jdbc.driverClassName}" /> <property name="url" value="${slave.jdbc.url}" /> <property name="username" value="${slave.jdbc.username}" /> <property name="password" value="${slave.jdbc.password}" /> <property name="initialSize" value="${slave.jdbc.initialSize}" /> <property name="minIdle" value="${slave.jdbc.minIdle}" /> <property name="maxActive" value="${slave.jdbc.maxActive}" /> <property name="maxWait" value="${slave.jdbc.maxWait}" /> <property name="removeAbandoned" value="${slave.jdbc.removeAbandoned}" /> <property name="removeAbandonedTimeout" value="${slave.jdbc.removeAbandonedTimeout}" /> <property name="timeBetweenEvictionRunsMillis" value="${slave.jdbc.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${slave.jdbc.minEvictableIdleTimeMillis}" /> <property name="validationQuery" value="${slave.jdbc.validationQuery}" /> <property name="testWhileIdle" value="${slave.jdbc.testWhileIdle}" /> <property name="testOnBorrow" value="${slave.jdbc.testOnBorrow}" /> <property name="testOnReturn" value="${slave.jdbc.testOnReturn}" /> </bean>