title: Consider defining a bean of type 'javax.persistence.EntityManagerFactory' in your configuration
body: <p>I am using Spring Boot 2.0.0.RC1 (It include Spring Framework 5.0.3.RELEASE), Hibernate 5.2.12.Final, JPA 2.1 API 1.0.0.Final .</p>
  
  <p>I have a class</p>
  
  <pre><code>package com.example;
  
  import org.hibernate.SessionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.factory.annotation.Qualifier;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  
  import javax.persistence.EntityManagerFactory;
  
  @Configuration
  public class BeanConfig {
  
      @Autowired
      EntityManagerFactory emf;
  
      @Bean
      public SessionFactory sessionFactory(@Qualifier("entityManagerFactory") EntityManagerFactory emf) {
          return emf.unwrap(SessionFactory.class);
      }
  
  }
  </code></pre>
  
  <p>Then error</p>
  
  <pre><code>Error
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Parameter 0 of method sessionFactory in com.example.BeanConfig required a bean of type 'javax.persistence.EntityManagerFactory' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'javax.persistence.EntityManagerFactory' in your configuration.
  
  
  Process finished with exit code 1
  </code></pre>
  
  <p>How to fix this?</p>