1:将上一篇的注解配置jdbc整合的业务接口的实现类里面的注解都去掉
2:修改配置文件如下:
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- 连接池启动时的初始值,一般两三条就够了 -->
<property name="initialSize" value="${jdbc.initialSize}"></property>
<!-- 连接池的最大值 -->
<property name="maxActive" value="${jdbc.maxActive}"></property>
<!-- 最大空闲值,当经过一个高峰时间后,连接池可以慢慢将用不到的连接释放一部分,一直减少到maxIdle为止 -->
<property name="maxIdle" value="${jdbc.maxIdle}"></property>
<!-- 最小空闲值,当空闲的连接数小于阀值时,连接池就会预申请一些连接,以免峰值到时来不及申请-->
<property name="minIdle" value="${jdbc.minIdle}"></property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<aop:config>
<aop:pointcut id="transactionPointcut" expression_r="execution(* service.imp..*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager" >
<tx:attributes>
<tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<bean id="suService" class="service.imp.SuServiceImpl">
<property name="dataSource" ref="dataSource"></property>
</bean>
</beans>
到此结束。