acegi TransactionInterceptor遇到spring2.x

本文探讨了在Spring 2.x中使用AOP进行事务管理时遇到的问题,特别是当引入Acegi的安全控制(ACL)时出现的冲突。作者详细描述了配置并尝试解决由AOP引发的问题,该问题阻止了TransactionInterceptor正常运作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一直使用spring2.x都没有问题,所有service都通过AOP注入。
现在用acegi的ACL,却发现原来的AOP影响而不能使用。以下是我的AOP
<!-- Transactional advice -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- methods starting with 'save', 'update' or 'remove' use the default transaction settings -->
<tx:method name="save*"/>
<tx:method name="delete*"/>
<tx:method name="merge*"/>
<tx:method name="remove*"/>

<!-- other methods are set to read only -->
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>

<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* cn.biaoming.service..*Service.*(..))" advice-ref="txAdvice"/>
</aop:config>

而TransactionInterceptor是这么定义的:
<bean id="articleService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces" value="cn.biaoming.service.ArticleService"/>
<property name="target"><ref local="articleServiceTager"/></property>
<property name="interceptorNames">
<list>
<idref local="articleServiceSecurity"/>
</list>
</property>
</bean>



<bean id="articleServiceSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="businessAccessDecisionManager"/></property>
<property name="afterInvocationManager"><ref local="afterInvocationManager"/></property>
<property name="objectDefinitionSource">
<value>
</value>
</property>
</bean>

现在只要把spring2.x 的AOP去掉,TransactionInterceptor就能正常工作,要不就报以下错误
WARN Cglib2AopProxy.doValidateClass(250) | Unable to proxy method [public final java.util.List $Proxy29.getLatestArticle(java.lang.String,int)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值