日期:2014-05-17 浏览次数:20836 次
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
default-autowire="byName">
<!-- 向spring注册AutowiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor、
PersistenceAnnotationBeanPostProcessor 以及 RequiredAnnotationBeanPostProcessor -->
<context:annotation-config></context:annotation-config>
<!-- 定义组件扫描的包名 -->
<context:component-scan base-package="edu.zjut" />
<!-- 导入属性配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:mysql.properties</value>
</list>
</property>
</bean>
<!-- context:property-placeholder location="classpath:mysql.properties" / -->
<!-- 定义使用C3P0连接池的数据源 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 指定连接数据库的JDBC驱动 -->
<property name="driverClass">
<value>${jdbc.driverClassName}</value>
</property>
<!-- 连接数据库所用的URL -->
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<!-- 连接数据库的用户名 -->
<property name="user">
<value>${jdbc.user}</value>
</property>
<!-- 连接数据库的密码 -->
<property name="password">
<value>${jdbc.password}</value>
</property>
<!-- 设置数据库连接池的最大连接数 -->
<property name="maxPoolSize">
<value>${jdbc.maxPoolSize}</value>
</property>
<!-- 设置数据库连接池的最小连接数 -->
<property name="minPoolSize">
<value>${jdbc.minPoolSize}</value>
</property>
<!-- 设置数据库连接池的初始化连接数 -->
<property name="initialPoolSize">
<value>${jdbc.initialPoolSize}</value>
</property>
<!-- 设置数据库连接池的连接的最大空闲时间,单位为秒 -->
<property name="maxIdleTime">
<value>${jdbc.maxIdleTime}</value>