You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SimpleBatchConfiguration which gets loaded by any of spring application, created transactionManager bean irrespective of whether that bean is already created or not. This results in overriding transaction manager
@ConditionalOnMissingBean could be used for resolution of this issues
As a workaround I've defined the exact same transaction manager I already have defined in other configuration class in my Spring Batch configuration class. So my application starts defining my transaction manager, then gets overridden by Spring Batch transaction manager and then gets overridden by my second definition of the transaction manager.
Sweet.
Adding a @ConditionalOnMissingBean seems to be easy enough. Am I missing something? Why isn't this addressed already? It's open since 2014.
I'm not sure what this magic @ConditionalOnMissingBean annotation is (I can't find Javadoc for it in Spring Framework or Spring Batch), but I've created a PR to try to address this issue:
In order to provide a custom transaction manager, a custom BatchConfigurer must be provided. For example:
@Bean
public BatchConfigurer batchConfigurer() {
return new DefaultBatchConfigurer() {
@Override
public PlatformTransactionManager getTransactionManager() {
return new MyTransactionManager();
}
};
}
Abhay opened BATCH-2294 and commented
SimpleBatchConfiguration which gets loaded by any of spring application, created transactionManager bean irrespective of whether that bean is already created or not. This results in overriding transaction manager
@ConditionalOnMissingBean
could be used for resolution of this issuesAffects: 3.0.1
Reference URL: http://stackoverflow.com/q/25303163/3073323
Issue Links:
("is depended on by")
Referenced from: pull request #609, and commits a68d700
Backported to: 4.1.0.M3
3 votes, 5 watchers
The text was updated successfully, but these errors were encountered: