1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <beans xmlns =" http://www.springframework.org/schema/beans"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xmlns : context =" http://www.springframework.org/schema/context"
5+ xsi : schemaLocation =" http://www.springframework.org/schema/beans
6+ http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd" >
7+
8+ <!-- 1. 关联数据库配置文件-->
9+ <context : property-placeholder location =" classpath:database.properties" />
10+
11+ <!-- 2. 连接池-->
12+ <bean id =" dataSource" class =" com.mchange.v2.c3p0.ComboPooledDataSource" >
13+ <property name =" driverClass" value =" ${jdbc.driver}" />
14+ <property name =" jdbcUrl" value =" ${jdbc.url}" />
15+ <property name =" user" value =" ${jdbc.username" />
16+ <property name =" password" value =" ${jdbc.password}" />
17+
18+ <!-- 如果池中数据连接不够时一次增长多少个 -->
19+ <property name =" acquireIncrement" value =" 5" />
20+ <!-- 初始化数据库连接池时连接的数量 -->
21+ <property name =" initialPoolSize" value =" 20" />
22+ <!-- 数据库连接池中的最大的数据库连接数 -->
23+ <property name =" maxPoolSize" value =" 30" />
24+ <!-- 数据库连接池中的最小的数据库连接数 -->
25+ <property name =" minPoolSize" value =" 10" />
26+ </bean >
27+
28+ <!-- 3. sqlSessionFactory-->
29+ <bean id =" sqlSessionFactory" class =" org.mybatis.spring.SqlSessionFactoryBean" >
30+ <property name =" dataSource" ref =" dataSource" />
31+
32+ <!-- 绑定MyBatis的配置文件-->
33+ <property name =" configLocation" value =" classpath:mybatis-config.xml" />
34+ </bean >
35+
36+ <!-- 配置dao接口扫描包, 动态的实现了Dao接口可以注入到Spring容器中!-->
37+ <bean class =" org.mybatis.spring.mapper.MapperScannerConfigurer" >
38+ <!-- 注入sqlSessionFactory-->
39+ <property name =" sqlSessionFactoryBeanName" value =" sqlSessionFactory" />
40+ <!-- 要扫描的dao包-->
41+ <property name =" basePackage" value =" top.clearlight.dao" />
42+ </bean >
43+
44+ </beans >
0 commit comments