1:將上一篇的註解配置jdbc整合的業務介面的實作類別裡面的註解都去掉
2:修改設定檔如下:
<?xml version="1.0" encoding="UTF-8"?><br /><beans xmlns="http://www.springframework.org/schema/beans"<br /> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"<br /> xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"<br /> xsi:schemaLocation=" </p><p>http://www.springframework.org/schema/beans</p><p>http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</p><p>http://www.springframework.org/schema/context</p><p>http://www.springframework.org/schema/context/spring-context-2.5.xsd</p><p>http://www.springframework.org/schema/aop</p><p>http://www.springframework.org/schema/aop/spring-aop-2.5.xsd</p><p>http://www.springframework.org/schema/tx</p><p> http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><br /><context:property-placeholder location="classpath:jdbc.properties" /></p><p><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><br /> <property name="driverClassName" value="${jdbc.driverClassName}"></property><br /> <property name="url" value="${jdbc.url}"></property><br /> <property name="username" value="${jdbc.username}"></property><br /> <property name="password" value="${jdbc.password}"></property><br /> <!-- 串連池啟動時的初始值,一般兩三條就夠了 --><br /> <property name="initialSize" value="${jdbc.initialSize}"></property><br /> <!-- 串連池的最大值 --><br /> <property name="maxActive" value="${jdbc.maxActive}"></property><br /> <!-- 最大空閑值,當經過一個高峰時間後,串連池可以慢慢將用不到的串連釋放一部分,一直減少到maxIdle為止 --><br /> <property name="maxIdle" value="${jdbc.maxIdle}"></property><br /> <!-- 最小空閑值,當閒置串連數小於閥值時,串連池就會預申請一些串連,以免峰值到時來不及申請--><br /> <property name="minIdle" value="${jdbc.minIdle}"></property><br /> </bean><br /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><br /> <property name="dataSource" ref="dataSource"></property><br /> </bean><br /> <aop:config><br /> <aop:pointcut id="transactionPointcut" expression_r="execution(* service.imp..*(..))"/><br /> <aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut"/><br /> </aop:config><br /> <tx:advice id="txAdvice" transaction-manager="transactionManager" ><br /> <tx:attributes><br /> <tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/><br /> <tx:method name="*"/><br /> </tx:attributes><br /> </tx:advice><br /><bean id="suService" class="service.imp.SuServiceImpl"><br /><property name="dataSource" ref="dataSource"></property><br /></bean><br /></beans></p><p>
到此結束。