title: No bean named 'transactionManager' available
body: <p>When I tried to create relationship using spring code,
  I am getting Transaction manager error. I am using Mysql and Neo4j database in my project. I tries different solution but not able to resolve.</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.NoSuchBeanDefinitionException: No
        bean named 'transactionManager' available: No matching
         PlatformTransactionManager bean found for qualifier
         'transactionManager' - neither qualifier match nor bean name match!</p>
  </blockquote>
  
  <p><strong>Pom.xml file as below</strong></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.10.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
              &lt;version&gt;1.5.10.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- For Neo4J Graph Database --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-neo4j&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;8.0.9-rc&lt;/version&gt;
          &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;version&gt;1.5.10.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
   &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;thymeleaf.version&gt;3.0.2.RELEASE&lt;/thymeleaf.version&gt;
          &lt;thymeleaf-layout-dialect.version&gt;2.1.1&lt;/thymeleaf-layout-dialect.version&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Application.class</p>
  
  <pre><code>    @SpringBootApplication
      @EnableTransactionManagement
      @EntityScan("projectone.entities")
      public class Application {
  
          public static void main(String[] args) {
              //For Starting application
              ApplicationContext applicationContext=SpringApplication.run(Application.class, args);
  
          }
      }
  </code></pre>
  
  <p>Database Configuration file:</p>
  
  <pre><code>@Configuration
  @EnableJpaRepositories(basePackages = {"projectone.mysql"},
          entityManagerFactoryRef = "dbEntityManager",
          transactionManagerRef = "dbTransactionManager")
  @EnableTransactionManagement
  public class DatabaseConfiguration {
  
       @Autowired
  
  
   private Environment env;
          @Bean
          @Primary
          public LocalContainerEntityManagerFactoryBean dbEntityManager() {
              LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
              em.setDataSource(dbDatasource());
              em.setPackagesToScan(new String[]{"projectone.mysql"});
              em.setPersistenceUnitName("dbEntityManager");
              HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
              em.setJpaVendorAdapter(vendorAdapter);
  
              HashMap&lt;String, Object&gt; properties = new HashMap&lt;&gt;();
  
              properties.put("hibernate.dialect",env.getProperty("hibernate.dialect"));
              properties.put("hibernate.show-sql",env.getProperty("jdbc.show-sql"));
  
  
              em.setJpaPropertyMap(properties);
              return em;
          }
          @Primary
          @Bean
          public DataSource dbDatasource() {
              DriverManagerDataSource dataSource
                      = new DriverManagerDataSource();
              dataSource.setDriverClassName(
                      env.getProperty("spring.datasource.driverClassName"));
              dataSource.setUrl(env.getProperty("spring.datasource.url"));
              dataSource.setUsername(env.getProperty("spring.datasource.username"));
              dataSource.setPassword(env.getProperty("spring.datasource.password"));
              return dataSource;
          }
          @Primary
          @Bean
          public PlatformTransactionManager dbTransactionManager() {
              JpaTransactionManager transactionManager
                      = new JpaTransactionManager();
              transactionManager.setEntityManagerFactory(
                      dbEntityManager().getObject());
              return transactionManager;
          }
  
  }
  </code></pre>
  
  <p>I tried minimal configuration by removing the database configuration class. After that my application is not running and I am getting Person is not a managed Bean error.</p>
  
  <p><a href="https://i.stack.imgur.com/Nee0x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nee0x.png" alt="enter image description here"></a></p>
  
  <p>If I use only @SpringBootApplication annotation then I am getting following Exception:
  It is throwing </p>
  
  <pre><code>    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mappingController': Unsatisfied dependency expressed through field 'branchService'; 
  nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'branchServiceImplementaion': Unsatisfied dependency expressed through field 'branchRepository'; 
  
  nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'branchRepository': Unsatisfied dependency expressed through method 'setSession' parameter 0; 
  
  nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.transaction.SharedSessionCreator#0': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.class]: Bean instantiation via factory method failed;
  
   nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is NullPointerException
  </code></pre>