注解版spring aop设置

来源:互联网 发布:java applet实例 编辑:程序博客网 时间:2024/06/07 03:34

1

<?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:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><!--Hibernate TransactionManagerAOP事物管理-->    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">        <property name="dataSource" ref="dataSource"/>    </bean><tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="save*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="add*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="insert*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="update*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="del*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="remove*" propagation="REQUIRED" rollback-for="com.spoe.exception.DAOException" /><tx:method name="get*" rollback-for="com.spoe.exception.DAOException" read-only="false" /><tx:method name="find*" rollback-for="com.spoe.exception.DAOException" read-only="true" /><tx:method name="*" rollback-for="com.spoe.exception.DAOException" read-only="true" /></tx:attributes></tx:advice><aop:config proxy-target-class="true"><aop:advisor pointcut="execution(* .*ServiceImpl.*(..))" advice-ref="txAdvice" /></aop:config></beans>

2 另外一种方式



原创粉丝点击