Spring注解驱动Transaction与AspectJ问题
我正在使用 AspectJ 编译时编织和 spring 3.O。和 Hibernate 3.0...AspectJ 编织对于日志记录等简单的事情工作得很好,但是对于事务 Sprong-aspects jar 也存在于 lib forlder 中,但它不能正常工作
<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>
,但事务支持仍然不起作用..
我正在使用这样的
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void invokeService() throws Exception {
insertUpdatePolicy();
}
日志记录不指定任何事务..当 Spring 容器中未定义该类时,事务可以与 spring aop 正常工作,但不能与spectj 一起工作
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请发布失败的实际代码。
启用日志记录。检查日志以查看事务是否正在被管理。如果是,那么您配置事务的方式可能存在问题。
Please post the actual code that is failing.
Enable logging. Check the logs to see if transactions are even being managed at all. If they are, then there is probably an issue with how you configured the transactions.
我已经找到了这个问题的答案,
我们需要记住一件事,我们需要将 spring-aspects.jar 放置到我的 Aspect Path 而不是 java 类路径。否则编织不会完成,事务也无法工作。
第二件事是我在 spring=bean 配置中缺少以下配置。
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.