Harryfin 2014年01月07日
Spring AOP配置死活不起作用,求救
无论怎么试都无法回滚

AOP配置如下:

<?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:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">

<!-- AOP事务 -->
<tx:advice id="DomainTxAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="create*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="load*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="select*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>

<aop:config proxy-target-class="true">
<aop:pointcut id="DomainServices" expression="execution(* rsj.frdc.domain..service..*.*(..))"/>
<aop:advisor pointcut-ref="DomainServices" advice-ref="DomainTxAdvice"/>
</aop:config>
</beans>


希望匹配的其中一个方法:
rsj.frdc.domain.datacleaner.schedule.fixplan.service.impl.DirtyRecordFixPlanService.save

方法中人为抛出一个异常:

public void save(DirtyRecordFixRule rule) {
dirtyRecordFixRuleDAO.insert(rule);
throw new RuntimeException("出错了!!!");
}


结果“dirtyRecordFixRuleDAO.insert(rule);”所插入的数据还是进数据库了,没有成功回滚。
...全文
1608 点赞 收藏 22
写回复
22 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告