Spring tx :annotation-driven works in eclipse, 但不在 tomcat 中

标签 spring tomcat annotations tomcat7 spring-annotations

我似乎对 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........

如果我删除 <tx:annotation-driven transaction-manager="transactionManager" />该项目将在 tomcat 和 eclipse 中正常启动。

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

谁能告诉我问题出在哪里?为什么它会在不报错的情况下销毁所有 bean?

最佳答案

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

关于Spring tx :annotation-driven works in eclipse, 但不在 tomcat 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11448071/

相关文章:

java - tomcat不是应用服务器是什么原因

java - Spring Autowiring 问题

java - 使用 Apache Thrift 和 TServlet 执行服务多路复用

java - 如何从 JdbcTemplate 获取 csv 列表?

javascript - Apache Web 服务器消息

java - 数据库查询挂到 DB2 服务器,在 java 代码中使用 tomcat 连接池

java - 是否可以定义通用接口(interface)并使用 Spring @CacheConfig?

java - 无法将数据作为列表从 spring Controller 传递到 View ?

Spring Jms @JmsListener 注释不起作用

jboss - JAXB-WS - 使用 @WebMethod 强制设置字段