Spring AOPインターセプタトランザクションが動作していません
問題
Spring AOPトランザクションは、インターセプタに従っていませんか?
<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>
”
matchGenericTxInterceptor
“トランザクションインターセプタは、
urlInterceptorInsert
、` urlInterceptorCommit`、 `urlInterceptorRelease`をインターセプトすると仮定しますが、期待どおりに動作していませんか?
解決策
3つのインターセプタは、トランザクションマネージャインターセプタ(
matchGenericTxInterceptor
)の前に実行されます。
これを修正するには、次のようにインターセプタxmlファイルのシーケンスを変更する必要があります(上にput
matchGenericTxInterceptor
)。
<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>