您的位置:首页 > 编程语言 > Java开发

Spring AOP Interceptor transaction is not working

2015-09-06 11:43 549 查看
The Spring AOP transaction is not working in following interceptors?

<bean id="testAutoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<idref bean="urlInterceptorInsert" />
<idref bean="urlInterceptorCommit" />
<idref bean="urlInterceptorRelease" />
<idref bean="matchGenericTxInterceptor" />
</list>
</property>
<property name="beanNames">
<list>
<idref local="urlBo" />
</list>
</property>
</bean>


The “
matchGenericTxInterceptor
” transaction interceptor, suppose to intercept
urlInterceptorInsert
,
urlInterceptorCommit
,
urlInterceptorRelease
, but it’s not work as expected?

Solution

The 3 interceptors are executed before transaction manager interceptor (
matchGenericTxIntercepto
r).

To fix it, you have to change the sequence of the interceptor xml file like following (put
matchGenericTxInterceptor
on top).

<bean id="testAutoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<idref bean="matchGenericTxInterceptor" />
<idref bean="urlInterceptorInsert" />
<idref bean="urlInterceptorCommit" />
<idref bean="urlInterceptorRelease" />
</list>
</property>
<property name="beanNames">
<list>
<idref local="urlBo" />
</list>
</property>
</bean>


Note

The sequence of Spring AOP interceptors do affect the functionality.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: