Spring aop事务未提交事务
我在 Apache Tomcat 6.0.29 上使用 Spring 3.0.3、MyBatis 3.0.2 和 mybatis-spring 1.0.0。
我使用了spring的声明式事务来进行事务管理。问题是交易对我不起作用。该交易仅有效一次,此后就无效。
我尝试检查我的所有配置,但没有任何线索。有什么指点吗?
我的配置看起来像这样 -
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="dtxops"
expression="execution(* com.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
</aop:config>
评论后编辑 -------------
我启动服务器并执行一些事务功能,有时它可以工作,有时则不能。有时连续工作5-6次后突然停止。
TX 管理器和 DS 配置 -
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef" value="true" />
<property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
</bean>
I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29.
I have used declarative transactions of spring for transaction management. The issue is that the transactions are not working for me. The transaction only works once and thereafter nothing.
I have tried checking all my configs but no clue. Any pointers?
My configurations looks like this -
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="dtxops"
expression="execution(* com.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
</aop:config>
EDIT after comment -------------
I start the server and execute some transactional functionality and some times it works and some times it does not. Sometimes it keeps on working for 5-6 times and then suddenly it stops.
TX Manager and DS config -
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef" value="true" />
<property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
</bean>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在 Spring 或 Tomcat 中配置了数据源? (Tomcat 有一些奇怪的默认设置,在每个语句后自动提交,我猜这使得在顶部运行 DataSourceTransactionManager 变得困难)
Have you configured you datasource in Spring or Tomcat? (Tomcat has some weird default setting that auto commits after every statement which I guess makes it hard to run a DataSourceTransactionManager on top)