123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:tx="http://www.springframework.org/schema/tx"
- 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-4.0.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="url" value="${jdbc.url}" />
- <property name="driverClassName" value="${jdbc.driver}" />
- <property name="maxActive" value="${pool.maxPoolSize}" />
- <property name="username" value="${jdbc.username}" />
- <property name="password" value="${jdbc.password}" />
- <!-- 超过时间限制是否回收 -->
- <property name="removeAbandoned" value="true" />
- <!-- 超时时间;单位为秒。180秒=3分钟 -->
- <property name="removeAbandonedTimeout" value="${pool.removeAbandonedTimeout}" />
- <!-- 配置获取连接等待超时的时间 -->
- <property name="maxWait" value="${pool.maxWait}" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" />
- <property name="validationQuery" value="${pool.validationQuery} " />
- <property name="testWhileIdle" value="true" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- </bean>
-
-
- <!-- 事务 控制 begin -->
- <bean name="transactionManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" order="10"/>
- <!-- 事务 控制 end -->
- <!-- 自动扫描mapping文件 start -->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="configLocation" value="classpath:mybatis-config.xml" />
- <!--<property name="mapperLocations" value="classpath*:com/edu/dao/**/*Mapper.xml"/>-->
- <property name="mapperLocations">
- <list>
- <!-- 表示在com/hywin包或以下所有目录中,以-Mapper.xml结尾所有文件 -->
- <value>classpath*:com/edu/dao/**/*.xml</value>
- </list>
- </property>
- <property name="typeAliasesSuperType" value="com.edu.base.BaseEntity" />
- <property name="configurationProperties">
- <props>
- <prop key="dialect">mysql</prop>
- </props>
- </property>
- <property name="plugins">
- <list>
- <bean class="com.edu.mybatis.SqlInterceptor" />
- </list>
- </property>
- </bean>
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.edu.dao" />
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
- </bean>
- <!-- 自动扫描mapping文件 end -->
- </beans>
|