<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!--开启自动扫描Bean -->
<context:component-scan base-package="com.lovo" />
<!--开启AOP注解支持 -->
<aop:aspectj-autoproxy />
<!--配置数据源(c3p0) -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!--指定数据库驱动 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<!--指定数据库URL -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/cbd_db"/>
<!--指定数据库用户名 -->
<property name="user" value="root"/>
<!--指定数据库密码 -->
<property name="password" value="root"/>
<!--指定连接池最大连接数 -->
<property name="maxPoolSize" value="20" />
<!--指定连接池最小连接数 -->
<property name="minPoolSize" value="1" />
<!--指定初始化连接池连接数(默认3个) -->
<property name="initialPoolSize" value="2" />
<!--指定连接池连接超时时长 -->
<property name="maxIdleTime" value="5000" />
<!--指定连接池耗尽时创建连接数 -->
<property name="acquireIncrement" value="2" />
<!--指定连接池检测线程间隔时长 -->
<property name="idleConnectionTestPeriod" value="3000" />
</bean>
<!--配置jdbc事务管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!--配置SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.lovo.entity" />
</bean>
<!--配置Mapper扫描模式,所有Mapper都继承SqlMapper接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.lovo.mapper" />
<property name="markerInterface" value="com.lovo.mapper.SqlMapper" />
</bean>
</beans>