我正在尝试为配置了 Spring Boot 的 Spring Batch/Spring Cloud 任务应用程序配置 XA/分布式事务。
我添加了以下依赖项,希望依赖于 spring boot 自动配置:
compile("org.springframework.boot:spring-boot-starter-jta-atomikos")
但是,以下两个类会导致配置两个事务管理器:
org.springframework.cloud.task.configuration.SimpleTaskConfiguration
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration
请参阅以下消息:
2016-07-18 21:46:19.952 INFO 18995 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.task.configuration.SimpleTaskConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.cloud.task.configuration.SimpleTaskConfiguration]
然后因为配置了一个PlatformTransactionManager
命名transactionManager
,所以我的 atomikos 自动配置没有被选中:
AtomikosJtaConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.transaction.jta.JtaTransactionManager,com.atomikos.icatch.jta.UserTransactionManager (OnClassCondition)
- @ConditionalOnMissingBean (types: org.springframework.transaction.PlatformTransactionManager; SearchStrategy: all) found the following [transactionManager] (OnBeanCondition)
有人可以帮我防止transactionManager
上述两个类对豆子的过度强迫吗?