Spring Annotation驱动程序使用AspectJ问题进行交易 [英] Spring Annotation driver Transaction with AspectJ problem

查看:193
本文介绍了Spring Annotation驱动程序使用AspectJ问题进行交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用AspectJ编译时编织和弹簧3.O.和Hibernate 3.0 ... AspectJ编织工作正常,但对于简单的事情,如日志记录,但这不能正常工作交易

 < tx:annotation-driven transaction-manager =transactionManager
mode =aspectjorder =1/>
< bean id =transactionManager
class =org.springframework.orm.hibernate3.HibernateTransactionManager>
< property name =sessionFactory>
< ref bean =sessionFactory/>
< / property>
< / bean>

Sprong-aspects jar也存在于lib forlder中,但事务支持仍然不起作用。



我是这样使用的$ / b>

  @Transactional(readOnly = false, propagate = Propagation.REQUIRED,rollbackFor = Exception.class)
public void invokeService()抛出异常{
insertUpdatePolicy();

$ / code $ / pre

记录doesn,t指定任何交易。交易与春天aop一起工作正常但没有在aspectj没有在spring容器中定义时使用aspectj

解决方案

我找到了这个问题的答案,



我们需要记住的一件事是,我们需要将spring-aspects.jar放到我的Aspect Path中,而不是java class path中。其他方式编织不完成,并且事务不起作用。



第二件事是我在spring = bean config中配置后丢失了。

 < bean class =org.springframework.transaction.aspectj.AnnotationTransactionAspectfactory-method =aspectOf> 
< property name =transactionManagerref =transactionManager/>


i am using AspectJ compile time weaving and spring 3.O. and Hibernate 3.0...AspectJ weaving is working fine for simple things like logging but this is not working correctly for Transaction

<tx:annotation-driven transaction-manager="transactionManager"
    mode="aspectj" order="1" />
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

Sprong-aspects jar is also present in the lib forlder but still transactional support is not working..

i am using like this

@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void invokeService() throws Exception {
    insertUpdatePolicy();
}

logging doesn,t specify any transactions..transactions are working fine with spring aop but not with aspectj when the class is not defined in the spring container

解决方案

i have found answer to this problem,

One thing we need to keep in mind that we need to place spring-aspects.jar to my Aspect Path instead of java class path.otherwise weaving is not done and transaction is not working.

Second thing i was missing following configuration in spring=bean config.

<bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf">
<property name="transactionManager" ref="transactionManager"/>

这篇关于Spring Annotation驱动程序使用AspectJ问题进行交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆