In Batch 5, its PlatformTransactionManager is no longer a bean. This hopefully makes it possible for us to configure Batch to use the auto-configuration transaction manager rather than creating a Batch-specific transaction manager as we currently do. This is complicated by @BatchDataSource. If a user configures a Batch-specific DataSource, we will need to ensure that the transaction manager that Batch is configured to use is using the same DataSource. This may be broken in 2.7 at the moment when JPA and @BatchDataSource are used together. I believe this can result in Batch using a JpaPlatformTransactionManager that's backed by the default entity manager factory and DataSource while using its own Batch-specific DataSource.
Comment From: wilkinsona
I discussed this today with @fmbenhassine and the expectation on the Batch side is that the user ensures that the DataSource and PlatformTransactionManager beans are aligned. We can adapt Boot's auto-config to the latest changes in Batch to continue to honour @BatchDataSource and use the auto-configured transaction manager. If the user has a more complex setup and they need to take control, they can use @EnableBatchProcessing or a DefaultBatchConfiguration sub-class to take control. In either case, Boot's auto-configuration will now back off.
Note that @EnableBatchProcessing causing the auto-configuration to back off is a breaking change. In 2.x, this annotation was required to enable Boot's auto-configuration. With the recent changes in Batch we can change this to align with other areas, such as Spring MVC and WebFlux where @EnableWebMvc or @EnableWebFlux causes the respective auto-configuration to back off.