【发布时间】:2015-10-13 13:37:37
【问题描述】:
我有一个 Spring Boot 应用程序作为 Spring JMS 侦听器。我已经为 Oracle 和 DB2 配置了多个数据源管理器。
每当我启动应用程序时,jms 侦听器容器都在寻找事务管理器 bean,并在找到两个 bean 时给出以下错误。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jms.JmsAnnotationDrivenConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.transaction.PlatformTransactionManager org.springframework.boot.autoconfigure.jms.JmsAnnotationDrivenConfiguration.transactionManager; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 2: db2TransactionManager,oracleTransactionManager
我不想维护 JMS 事务。我怎样才能实现它或者我们怎样才能禁用 jms 事务功能?
以下是我在主 Spring Boot 类中添加的注释。我也在使用 Spring Data 存储库
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})
@ComponentScan(basePackages = "com.deere.oracledataupdate.*")
//@EnableJpaRepositories(basePackages ="com.deere.oracledataupdate.dao.springdata")
@EntityScan(basePackages = "com.deere.oracledataupdate.*")
@PropertySource({ "classpath:application-${IafConfigSuffix}.properties" })
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
【问题讨论】:
-
您使用的是哪个 Spring Boot 版本。
-
我正在使用 1.2.3.RELEASE 的 spring boot
-
更新到最新的 1.2.6... JMS 自动配置的早期版本依赖于
PlatformTransactionManager较新的版本特定的JtaTransactionManager因为它(通常)在那里进行交易是有意义的. -
将版本更改为最新版本后它工作了 :) 谢谢 Deinum