<beans xmlns=" xmlns:xsi="http://www.springframework.org/schema/beans <!-- 攔截配置 --> <!-- 切入點 --> <!-- Enable @Transactional support -->
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--說明事務類別 read-only表示不支持事務,propagation的事務類別與EJB保持一致-->
<tx:method name="find*" read-only="true" />
<tx:method name="get*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<!-- Dao層事務 說明你要攔截那些包下面的類的方法-->
<aop:advisor id="daoTx" advice-ref="txAdvice" pointcut="execution(* *..dao.impl.*.*(..))" order="0" />
<!-- service層事務 -->
<aop:advisor id="serviceTx" advice-ref="txAdvice" pointcut="execution(* *..service.impl.*.*(..))" order="1" />
</aop:config>
<tx:annotation-driven />
<!-- 事務管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
。。。下面是具體的dataSource配置
或下載附件http://www.aygfsteel.com/Files/yiqi/application-resources.rar