首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring tx:advice 跟 aop:config 配置事务 2

2012-10-30 
spring tx:advice 和 aop:config 配置事务 2?xml version1.0 encodingUTF-8??? ?? beans xmlns

spring tx:advice 和 aop:config 配置事务 2

<?xml version="1.0" encoding="UTF-8"?>??
??
<beans xmlns="http://www.springframework.org/schema/beans"??
??? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
??? xmlns:aop="http://www.springframework.org/schema/aop"??
??? xmlns:tx="http://www.springframework.org/schema/tx"??
??? xsi:schemaLocation="???
??????????? http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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">??
??? <bean id="testAction" ref="templatesService"></property>??
??? </bean>??
??
??? <bean id="templatesService"??
??????? ref="templatesDAO" />??
??? </bean>??
??
??? <bean id="templatesDAO" ref="sessionFactory"></property>??
??? </bean>??
??
??
??? <!--定义数据源-->??
??? <bean id="dataSource"??
??????? />??
??????? </property>??
??????? <property name="mappingResources">??
??????????? <list>??
??????????????? <!--以下用来列出所有的PO映射文件-->??
??????????????? <value>test/mapping/Tao_Templates.hbm.xml</value>??
??????????? </list>??
??????? </property>??
??????? <property name="hibernateProperties">??
??????????? <props>??
??????????????? <prop key="hibernate.dialect">??
??????????????????? org.hibernate.dialect.Oracle10gDialect???
??????????????? </prop>??
??????????????? <prop key="hibernate.show_sql">true</prop>??
??????????????? <!--此处用来定义hibernate的SessionFactory的属性:???
??????????????????? 不同数据库连接,启动时选择create,update,create-drop -->??
??????????????? <prop key="hibernate.hbm2ddl.auto">update</prop>??
??????????? </props>??
??????? </property>??
??? </bean>??
??
??? <bean id="transactionManager"??
??????? />??
??????? </property>??
??? </bean>??
??
??? <!-- 事务通知 -->??
??? <tx:advice id="txAdvice" transaction-manager="transactionManager">??
??????? <tx:attributes>??
??????????? <tx:method name="add*" propagation="REQUIRED" />??
??????????? <tx:method name="del*" propagation="REQUIRED" />??
??????????? <tx:method name="mod*" propagation="REQUIRED" />??
??????????? <tx:method name="*" read-only="true" />??
??????? </tx:attributes>??
??? </tx:advice>??
??
??? <!-- Spring AOP config -->??
??? <aop:config >??
??????? <!-- 切入点 -->??
??????? <aop:pointcut id="newServicesPointcut"??
??????????? expression="execution(* test.dao.impl.*.*(..))" />??
??????? <aop:pointcut id="newServicesPointcut2"??
??????????? expression="execution(* com.yx.news.model.*.*(..))" />??
??????? <aop:advisor advice-ref="txAdvice"??
??????????? pointcut-ref="newServicesPointcut" />??
??????? <aop:advisor advice-ref="txAdvice"??
??????????? pointcut-ref="newServicesPointcut2" />??
??? </aop:config>??
??
</beans>??


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zj978723/archive/2009/09/02/4511804.aspx

热点排行