• Spring AOP Interceptor transaction is not working


    Problem

    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 (matchGenericTxInterceptor).

    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.

  • 相关阅读:
    JS 获取浏览器窗口大小方面的
    可以直接拿来用的15个jQuery代码片段
    JS 键盘方面的
    JAVA 实现DES MD5加密
    Spring SpringMvc Hibernate整合
    easyUI comboselector使用
    页面中嵌套html代码显示
    在IntelliJ上操作GitHub
    Maven项目配置第三方jar包
    JSP自定义标签
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4751819.html
Copyright © 2020-2023  润新知