Spring Boot/Spring Batch アプリケーションで Atomikos を動作させようとしています。
私のコードの関連部分は次のとおりです。
データソース構成:
@Configuration
public class DatasourceConfiguration extends AbstractCloudConfig {
@Bean
@Qualifier("batch_database")
public DataSource batchDatasource() {
return connectionFactory().dataSource("batch_database");
}
@Bean
public PlatformTransactionManager transactionManager(){
return new JtaTransactionManager();
}
@Bean
public TaskConfigurer configurer(){
return new DefaultTaskConfigurer(batchDatasource());
}
}
Atomikos 自動構成の依存関係:
compile("org.springframework.boot:spring-boot-starter-jta-atomikos")
私のapplication.properties
:
spring.datasource.application.driver-class-name=org.postgresql.xa.PGXADataSource
spring.datasource.batch.driver-class-name=org.postgresql.xa.PGXADataSource
自動構成レポートは次のとおりです。
DataSourceTransactionManagerAutoConfiguration matched
- @ConditionalOnClass classes found: org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition)
DataSourceTransactionManagerAutoConfiguration.DataSourceTransactionManagerConfiguration matched
- @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found the following [batchDatasource, applicationDatasource, batch_database, application_database, database] (OnBeanCondition)
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)
AtomikosJtaConfiguration.AtomikosJtaJmsConfiguration did not match
- required @ConditionalOnClass classes not found: javax.jms.Message (OnClassCondition)
- Ancestor 'org.springframework.boot.autoconfigure.transaction.jta.AtomikosJtaConfiguration' did not match (ConditionEvaluationReport.AncestorsMatchedCondition)
Atomikos が自動構成されない理由がわかりません... 誰か助けてもらえますか?
edit : JTA transactionManager Bean をコメントアウトしたところ、次の自動構成レポートが表示されました。
DataSourceTransactionManagerAutoConfiguration matched
- @ConditionalOnClass classes found: org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition)
DataSourceTransactionManagerAutoConfiguration.DataSourceTransactionManagerConfiguration matched
- @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found the following [batchDatasource, applicationDatasource, batch_database, application_database, database] (OnBeanCondition)
TransactionAutoConfiguration matched
- @ConditionalOnClass classes found: org.springframework.transaction.support.TransactionTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition)
- @ConditionalOnSingleCandidate (types: org.springframework.transaction.PlatformTransactionManager; SearchStrategy: all) found a primary candidate amongst the following [transactionManager] (OnBeanCondition)
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)
AtomikosJtaConfiguration.AtomikosJtaJmsConfiguration did not match
- required @ConditionalOnClass classes not found: javax.jms.Message (OnClassCondition)
- Ancestor 'org.springframework.boot.autoconfigure.transaction.jta.AtomikosJtaConfiguration' did not match (ConditionEvaluationReport.AncestorsMatchedCondition)
Atomikos トランザクション マネージャーがピックアップされていることを確認するにはどうすればよいですか?
編集2TransactionManager
:次のようにクラスを除外しました:
@EnableAutoConfiguration(exclude = {DataSourceTransactionManagerAutoConfiguration.class, TransactionAutoConfiguration.class})
しかし、私はまだ私にいくつかのクラスの1つを強制しSimpleBatchConfiguration
ているようです:SimpleTaskConfiguration
TransactionManager
2016-07-12 11:27:57.846 INFO 4851 --- [ 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]
AtomikosJtaConfiguration
一致しない原因...
Atomikos の自動構成を機能させるためのベスト プラクティスを教えてください。