In the Batch auto-configuration we use a plain BasicBatchConfigurer that will ultimately create another PlatformTransactionManager. We should probably:
- Make sure that any auto-configuration that can create a
PlatformTransactionManagerruns before the batch one - Have an extension of
BasicBatchConfigurerwherecreateTransactionManageris overridden to provide the one that we have
ping @dsyer
Comment From: snicoll
Wow, ok. So @EnableBatchProcessing does trigger SimpleBatchConfiguration which itselfs looks for a BatchConfigurer.
SimpleBatchConfiguration forces the exposure of a PlatformTransactionManager coming from the configurer so all in all we're back where we started. If I make some additional changes to pass along the auto-configured PlatformTransactionManager things break in a very weird way.
What bugs me is that as soon as you add batch in your app your PlatformTransactionManager changes and since the batch auto-configuration happens quite late in that process, there isn't a way to workaround that.
Comment From: snicoll
OK so maybe I should extend from SimpleBatchConfiguration and add @ConditionalOnMissingBeanon the transaction manager? But that won't create a lazy proxy thing anymore. Any reason why we have that @dsyer ?
Comment From: snicoll
@benas Did you face this issue with Spring Batch? Any recommendation to "bypass" the exposure of a PlatformTransactionManager?
Comment From: snicoll
FTR, Mahmoud and I had a meeting on this one and there's not much we can do without a change in Spring Batch itself. I've created BATCH-2788.
Comment From: hpoettker
I think this issue can be closed. It has been adressed with #32330.
Comment From: wilkinsona
I can indeed. Thanks, @hpoettker.
For anyone else finding this issue, I think it's worth noting here that Boot 3.0 has removed the need to use @EnableBatchProcessing in a Boot app. Like other auto-configurations, batch processing is now enabled automatically based on the classpath. Using @EnableBatchProcessing in your app will now switch off Boot's auto-configuration, allowing you to take complete control over Spring Batch's configuration.