<?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" 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.xsd" default-autowire="byName"> <context:component-scan base-package="com.dili.titan.dao" /> <!--<bean id="abstractDataSource" abstract="true" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">--> <!--<property name="driverClass" value="${jdbc.driverClass}" />--> <!--<property name="idleConnectionTestPeriodInMinutes" value="${jdbc.idleConnectionTestPeriod}" />--> <!--<property name="idleMaxAgeInMinutes" value="${jdbc.idleMaxAge}" />--> <!--<property name="maxConnectionsPerPartition" value="${jdbc.maxConnectionsPerPartition}" />--> <!--<property name="minConnectionsPerPartition" value="${jdbc.minConnectionsPerPartition}" />--> <!--<property name="partitionCount" value="${jdbc.partitionCount}" />--> <!--<property name="acquireIncrement" value="${jdbc.acquireIncrement}" />--> <!--<property name="statementsCacheSize" value="${jdbc.statementsCacheSize}" />--> <!--<property name="releaseHelperThreads" value="${jdbc.releaseHelperThreads}" />--> <!--</bean>--> <!--<bean id="masterDataSource" parent="abstractDataSource">--> <!--<property name="jdbcUrl" value="${jdbc.jdbcUrl}" />--> <!--<property name="username" value="${jdbc.username}" />--> <!--<property name="password" value="${jdbc.password}" />--> <!--</bean>--> <bean id="masterDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClass}"/> <property name="url" value="${jdbc.jdbcUrl}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="filters" value="stat"/> <property name="maxActive" value="${jdbc.maxActive}"/> <property name="initialSize" value="${jdbc.initialSize}"/> <property name="maxWait" value="${jdbc.maxWait}"/> <property name="minIdle" value="${jdbc.minIdle}"/> <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/> <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/> <property name="validationQuery" value="SELECT now()"/> <property name="testWhileIdle" value="true"/> <property name="testOnBorrow" value="false"/> <property name="testOnReturn" value="false"/> <property name="poolPreparedStatements" value="${jdbc.poolPreparedStatements}"/> <property name="maxOpenPreparedStatements" value="${jdbc.maxOpenPreparedStatements}"/> </bean> <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="masterDataSource" /> <property name="configLocation" value="classpath:com.diligrp.titan.dao.sqlmap/com.diligrp.titan.dao.sqlmap-config.xml" /> </bean> <bean id="sqlTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sessionFactory" /> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="masterDataSource" /> </bean> </beans>