123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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:aop="http://www.springframework.org/schema/aop" 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.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd">
-
- <!-- 配置数据源 测试数据库 mysql -h 192.168.1.87 -uroot -padmin123-->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <!-- 基本属性 url、user、password -->
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://127.0.0.1:3306/efunbox_recmd" />
- <property name="username" value="root" />
- <property name="password" value="223732" />
- <property name="initialSize" value="1" />
- <property name="minIdle" value="1" />
- <property name="maxActive" value="20" />
- <property name="maxWait" value="60000" />
- <!-- 超过时间限制是否回收 -->
- <property name="removeAbandoned" value="true" />
- <!-- 超过时间限制多长; -->
- <property name="removeAbandonedTimeout" value="180" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="300000" />
- <!-- 用来检测连接是否有效的sql,要求是一个查询语句-->
- <property name="validationQuery" value="SELECT 1" />
- <!-- 申请连接的时候检测 -->
- <property name="testWhileIdle" value="true" />
- <!-- 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 -->
- <property name="testOnBorrow" value="false" />
- <!-- 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 -->
- <property name="testOnReturn" value="false" />
- </bean>
- <!-- Mybatis文件 -->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="configLocation" value="classpath:mybatis-config.xml" />
- <property name="dataSource" ref="dataSource" />
- <!-- 映射文件路径 -->
- <!-- <property name="mapperLocations" value="cn/efunbox/mapping/*.xml" />-->
- </bean>
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="cn.efunbox.dao" />
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
- </bean>
- <!-- 事务管理器 -->
- <bean id="transactionManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
-
- <tx:annotation-driven transaction-manager="transactionManager" />
- </beans>
|