Reputation: 31
I have a spring batch job as part of an application. The application already has a TransactionManager and when I use the @EnableBatchProcessing Spring Batch also tries to create a TransactionManager in the SimpleBatchConfiguration. I can't use the override bean property here as I need to use the application's TransactionManager. I was thinking creating a Custom annotation like the @EnableBatchProcessing and use a custom configuration which does not create a TransactionManager. Is there a better way to set or configure SpringBatch to use the existing application's TransactionManager and not create it's own?
Upvotes: 1
Views: 1767
Reputation: 31745
This is a known issue: https://github.com/spring-projects/spring-batch/issues/816, which was fixed in v5.0.0-M1.
Is there a better way to set or configure SpringBatch to use the existing application's TransactionManager and not create it's own?
Unless you remove the usage of @EnableBatchProcessing
, you won't be able to prevent the exposure of the transaction manager bean because of the @Bean
annotation on org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration#transactionManager
.
That said, you can provide a custom BatchConfigurer
and override getTransactionManager
to instruct Spring Batch to use a custom transaction manager. This is mentioned in documentation here.
Upvotes: 1