New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] #476

Closed
YaraslauBarysenka opened this Issue Dec 7, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@YaraslauBarysenka

YaraslauBarysenka commented Dec 7, 2016

Expectations versus reality

Preconditions

  • javers version is 2.7.2;
  • using javers spring integration (please see JaversConfiguration.java file in the application example);
  • two transaction managers are available in spring context;
  • using org.javers.spring.jpa.TransactionalJaversBuilder to build a org.javers.core.Javers object.

Current Result

We got excaption like this: Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 2: transactionManager,secondTransactionManager

Expected Result

Javers library provides avalible method to set PlatformTransactionManager when we build a org.javers.core.Javers object.

If Javers can do this could you please provide information how to do that?

Runnable test case

The application to reproduce issue here: javers-bug-example.zip

In order to reproduce the issue please execute "mvn clean package" in root folder.

P.S.

If you have questions, please let's me know.
Thank you in advance.

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Dec 8, 2016

Thanks for hight quality report, we will add support for selecting transaction manager

bartoszwalacik added a commit that referenced this issue Dec 8, 2016

#476
support for multiple transaction managers
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Dec 9, 2016

released in 2.8.0, now you pass concrete txManager instance (no autowiring) :

    @Bean
    public Javers javers(PlatformTransactionManager txManager) {
        JaversSqlRepository sqlRepository = SqlRepositoryBuilder
                .sqlRepository()
                .withConnectionProvider(jpaConnectionProvider())
                .withDialect(DialectName.H2)
                .build();

        return TransactionalJaversBuilder
                .javers()
                .withTxManager(txManager)
                .withObjectAccessHook(new HibernateUnproxyObjectAccessHook())
                .registerJaversRepository(sqlRepository)
                .build();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment