applicationContext.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!-- jdbc-odbc桥连 -->
<beans>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/jdbc.properties</value>
</list>
</property> </bean>
<!--单例数据库连接
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
destroy-method="close">
<property name="url">
<value>${database.url}</value>
</property>
<property name="driverClassName">
<value>${database.driver}</value>
</property>
<property name="username">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
<property name="autoCommit">
<value>true</value>
</property>
</bean>
-->
<!-- c3p0 对应数据库的数据连接池  -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="jdbcUrl">
<value>${database.url}</value>
</property>
<property name="driverClass">
<value>${database.driver}</value>
</property>
<property name="user">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
</bean> <!--apache 对应数据库的数据连接池
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
<property name="url">
<value>${database.url}</value>
</property>
<property name="driverClassName">
<value>${database.driver}</value>
</property>
<property name="username">
<value>${database.user}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
<property name="defaultAutoCommit">
<value>true</value>
</property> 

</bean> --> <!-- 配置事务管理 -->
<!-- 不管采用哪种方法 下面的这个bean都是必须的 它是事物管理器-->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean> <!-- 事务的属性 -->
<bean id="transactionAttributeSource"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target">
<ref bean="playerServiceTarget" />
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource" />
</property>
</bean> <bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="playerDaoJdbc" class="org.vieri.daoJdbc.PlayerDaoJdbc">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>
<bean id="playerServiceTarget"
class="org.vieri.service.IPlayerServiceImpl" singleton="false">
<property name="playerDao">
<ref bean="playerDaoJdbc" />
</property>
</bean>
</beans>