Problem

The Spring AOP transaction is not working in following interceptors?

 <bean 
    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 
        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.

相关文章:

  • 2021-07-06
  • 2021-10-19
  • 2022-12-23
  • 2021-10-29
  • 2021-12-24
  • 2021-04-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-11-03
  • 2021-08-15
  • 2021-06-20
相关资源
相似解决方案