I am facing issue while creating bean for HibernateTransactionManager in a Spring Batch Application.
Application is unable to create bean for transactionManager for HibernateTransactionManager as it is already created by SimpleBatchConfiguration class while enabling @EnableBatchProcessing annotation.
After further analysis, I found that SimpleBatchConfiguration class creates a transactionManager bean of type PlatformTransactionManager. This PlatformTransactionManager class extends TransactionManager.
Also while trying to create transactionManager bean for HibernateTransactionManager (this also extends TransactionManager class), application is failed to start saying that
No qualifying bean found for org.springframework.transaction.TransactionManager. Expecting one but found two: transactionManager,transactionManagerBean.
Below is the bean defination for transactionManagerBean.
<bean id="transactionManagerBean" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernateSessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManagerBean"/>
I am using: Spring batch: 4.2.7-RELEASE Spring boot: 2.3.11-RELEASE Hibernate: 5.4.31-Final Spring-cloud-starter: 2.2.5-RELEASE
Can anyone please help.