<beans xmlns=" xmlns:xsi="http://www.springframework.org/schema/beans 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> <!-- Enable @Transactional support --> <tx:annotation-driven /> <!-- 事務管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean>。。。下面是具體的dataSource配置或下載附件http://www.tkk7.com/Files/yiqi/application-resources.rar posted on 2012-03-13 10:56 民工二代 閱讀(304) 評論(0) 編輯 收藏
<!-- 攔截配置 --> <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>
<!-- Enable @Transactional support --> <tx:annotation-driven /> <!-- 事務管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean>。。。下面是具體的dataSource配置或下載附件http://www.tkk7.com/Files/yiqi/application-resources.rar