Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

The bean 'org.springframework.transaction.config.internalTransactionAdvisor' already registered

Ask Question

I have defined a trivial SpringBoot Hibernate app, copy-pasted from sample code found in a random site on the Internet. The hopefully relevant portions of my spring.xml look like this:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
... details ommitted ...
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
... details ommitted ...
<bean id="transactionManager"
    class="org.springframework.orm.hibernate5.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />

Why do I get this error?

The bean 'org.springframework.transaction.config.internalTransactionAdvisor', defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class], could not be registered. A bean with that name has already been defined in null and overriding is disabled.

Other things I have already tried

  • Using org.springframework.jdbc.datasource.DataSourceTransactionManager - same error
  • Using org.springframework.orm.jpa.JpaTransactionManager - same error
  • Removing the transactionManager bean - ok my SpringBoot app works but now all my JUnit tests break
  • Maybe check this answer, I was getting the same error after upgrading to Spring Boot 2.x from 1.5.xx : stackoverflow.com/questions/51367566/… – lincolnadym Jul 16, 2019 at 16:27 Came here after trying to migrate from SpringBoot 1.5.9 to 2.2.1. Trying @lincolnadym link... – Jefferson Quesado Nov 18, 2019 at 20:00

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.