【问题标题】:Spring tx:annotation-driven works in eclipse, but not in tomcatSpring tx:annotation-driven 在 Eclipse 中有效,但在 tomcat 中无效
【发布时间】:2012-07-12 08:44:44
【问题描述】:

我似乎对 spring 注释驱动的事务管理和 tomcat 有问题。 这些是我在项目中使用的一些 bean:

<bean id="dataSource" class="service.myBatis.RoutingDataSource"> </bean>        

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
    <property name="dataSource" ref="dataSource"/>              
</bean>  

<tx:annotation-driven  transaction-manager="transactionManager"  />

当我在 Eclipse 中运行项目时,一切正常。但是当我在 tomcat 中运行项目时,它并没有超越 bean 的创建。它也不会给我一个错误或任何错误的指示。

日志显示它以实例化 bean 完成,然后突然销毁所有 bean:

[DEBUG] 12 jul 09:28:55.888 AM localhost-startStop-1 [org.springframework.beans.factory.support.DefaultListableBeanFactory]
Finished creating instance of bean 'org.springframework.transaction.config.internalTransactionAdvisor'

[INFO] 12 jul 09:28:55.895 AM localhost-startStop-1 [org.springframework.beans.factory.support.DefaultListableBeanFactory]
Destroying singletons in........

如果我删除 &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt; 行,项目将在 tomcat 和 eclipse 中正常启动。

通常,如果某些东西在 Eclipse 中有效,而在 tomcat 中无效,则这是由于 tomcat 未找到某些类/lib 或资源造成的。不过我不知道是什么原因造成的

谁能告诉我问题是什么?为什么它会销毁所有的bean而不报错?

【问题讨论】:

标签: spring tomcat annotations tomcat7 spring-annotations


【解决方案1】:

我想通了。导致问题的不是春天,而是我项目中的其他问题。错误被放入一些 tomcat 日志而不是控制台。所以看起来没有错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 1970-01-01
    相关资源
    最近更新 更多