将 AspectJ 与 iBatis、Spring 结合使用时不应用事务
我正在使用由 Axis 2 Web 服务调用的 iBatis 2.3.4。我在构建期间使用 AspectJ 编织。
我有以下 Spring 应用程序上下文:
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<ref bean="dataSourceImpl" />
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj" proxy-target-class="true"/>
我有一个具有 @Transactional 注释的 Web 服务操作,因此:
@Override
@Transactional(propagation=Propagation.REQUIRED)
public void doStuff() {
System.out.println("--> isActualTransactionActive: " + TransactionSynchronizationManager.isActualTransactionActive());
.
.
.
}
当我调用 Web 服务时,我看到
--> isActualTransactionActive: false
,因为交易从未实际应用。有人将 AspectJ 与 iBatis 结合使用吗?
I am using iBatis 2.3.4 being called by an Axis 2 web service. I am using AspectJ weaving during the build.
I have the following Spring application context:
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<ref bean="dataSourceImpl" />
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj" proxy-target-class="true"/>
I have a web service operation which has a @Transactional annotation, thus:
@Override
@Transactional(propagation=Propagation.REQUIRED)
public void doStuff() {
System.out.println("--> isActualTransactionActive: " + TransactionSynchronizationManager.isActualTransactionActive());
.
.
.
}
When I call the web service I see
--> isActualTransactionActive: false
as the transaction is never actually applied. Has anyone used AspectJ in combination with iBatis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您启用了加载时编织吗?
编辑:
您可能还需要:
在 META-INF/context.xml 中(以避免必须使用 -javaagent 命令行参数。
Have you enabled load-time weaving?
EDIT:
You'll probably also need:
in your META-INF/context.xml (to avoid having to use the -javaagent command line parameter.