title: hibernate does not create sessionFactory bean
body: <p>I'm new to hibernate and using it with spring 5, I've a configuration class which creates sessionFactory bean but it does not work(create), I get this error when running my project  :</p>
  
  <blockquote>
    <p><strong>exception</strong> is org.springframework.beans.factory.BeanCreationException: <strong>Error
    creating bean with name 'sessionFactory' defined in
    com.t4b.project.priceBuy.configuration.HibernateConfig:
    Post-processing of merged bean definition failed;</strong> nested exception
    is java.lang.IllegalStateException: Failed to introspect Class
    [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from
    ClassLoader [ParallelWebappClassLoader: priceBuy</p>
  </blockquote>
  
  <pre><code>// configuration class
  
      @Configuration
      public class HibernateConfig {
  
  
          @Bean
          public LocalSessionFactoryBean sessionFactory() {
  
          LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
  
          sessionFactoryBean.setHibernateProperties(properties());
          sessionFactoryBean.setAnnotatedClasses(Tarif.class);
  
          return sessionFactoryBean;
  
          }
  
          @Bean
          public Properties properties() {
  
              Properties properties = new Properties();
  
              properties.setProperty(AvailableSettings.URL, "jdbc:mysql://localhost:3306/SPRING-LEARN");
              properties.setProperty(AvailableSettings.USER, "root");
              properties.setProperty(AvailableSettings.PASS, "carrow");
              properties.setProperty(AvailableSettings.DIALECT, MySQL5Dialect.class.getName());
              properties.setProperty(AvailableSettings.SHOW_SQL, String.valueOf(true));
              properties.setProperty(AvailableSettings.HBM2DDL_AUTO, "update");
  
  
              return properties;
          }
  
      }
  
  
      public class PriceBuyWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
          @Override
          protected Class&lt;?&gt;[] getRootConfigClasses() {
              // TODO Auto-generated method stub
              return null;
          }
  
          @Override
          protected Class&lt;?&gt;[] getServletConfigClasses() {
              // TODO Auto-generated method stub
              return new Class[] {PriceBuyWebApplicationConfiguration.class, ConverterConfig.class, HibernateConfig.class};
          }
  
          @Override
          protected String[] getServletMappings() {
              // TODO Auto-generated method stub
              return new String[] {"/"};
          }
  
  
      }
  
  
      // controller
  
  
      @RestController
      @RequestMapping("/tarif")
      public class TarifController {
  
          @Autowired
          TarifDao TarifDao;
  
          @RequestMapping(method =  RequestMethod.GET)
          public String saveTarif(Model model) {
              Tarif tarif = new Tarif("CK09", 1234);
  
              TarifDao.insertTarif(tarif);
  
              return "tarif";
          }
      }
  
      // tarif class
  package com.t4b.project.priceBuy.entities;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "tarif")
  public class Tarif {
  
      @Id
      @Column(name ="code")
      private String code;
  
      @Column(name ="tax")
      private double tax;
  
      public Tarif(String code, double tax) {
          this.code = code;
          this.tax  = tax; 
      }
  
      public String getCode() {
          return code;
      }
  
      public void setCode(String code) {
          this.code = code;
      }
  
      public double getTax() {
          return tax;
      }
  
      public void setTax(double tax) {
          this.tax = tax;
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + ((code == null) ? 0 : code.hashCode());
          long temp;
          temp = Double.doubleToLongBits(tax);
          result = prime * result + (int) (temp ^ (temp &gt;&gt;&gt; 32));
          return result;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          Tarif other = (Tarif) obj;
          if (code == null) {
              if (other.code != null)
                  return false;
          } else if (!code.equals(other.code))
              return false;
          if (Double.doubleToLongBits(tax) != Double.doubleToLongBits(other.tax))
              return false;
          return true;
      }
  
      @Override
      public String toString() {
          return "Tarif [code=" + code + ", tax=" + tax + "]";
      }
  
  
  
  
  
  
  }
  </code></pre>