Skip to content

PlatformTransactionManager bean is exposed unconditionally [BATCH-2788] #816

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stéphane Nicoll opened BATCH-2788 and commented

While this can't be changed easily as it will break backward compatibility, Spring Batch should not expose a PlatformTransactionManager unconditionally (see SimpleBatchConfiguration).

Spring Boot 2.1 has a mode enabled by default that throws an exception on startup if a bean is overridden. If a user defines its own transaction manager with Spring Batch, they will have to disable the flag as the application will fail. This isn't really expected as Spring Boot is supposed to handle and detect such scenario.

Arguably, Spring Boot should provide whatever PlatformTransactionManager and Spring Batch should be configured to use this. We can't implement this mode at the moment as Spring Batch exposes a PlatformTransactionManager itself.

This problem has been raised in several places (i.e. BATCH-2294). IMO, the resolution is incorrect: this is not about customizing the transaction manager to use, this is about exposing a bean in the context that may not be Spring Batch's responsibility in the first place. Besides, it is very likely that the transaction manager instance the user provides via the BatchConfigurer is already a bean so exposing it again feels wrong in the first place.


Affects: 4.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions