title: Class SpringHibernateJpaPersistenceProvider does not implement the requested interface PersistenceProvider
body: <p>I'm stumped - I haven't used Hibernate in several years and then, never with Spring Boot.  Spring Boot but never with Hibernate or JPA.  So i'm trying to figure out how to get this to work for my job - I'm supposed to demo something Monday and if I can get 'this' to work, I'll copy it over to my work laptop and change the details of course.  Btw - here's the message I get - I had to shorten it in the title:</p>
  <p>&quot;Class org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider does not implement the requested interface javax.persistence.spi.PersistenceProvider&quot;</p>
  <p>I have the &quot;main&quot; class - TestWebApplication:</p>
  <pre><code>package net.draconia.testWeb;
  
  import java.util.Properties;
  
  import javax.sql.DataSource;
  
  import org.apache.commons.dbcp2.BasicDataSource;
  
  import org.springframework.boot.SpringApplication;
  
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.orm.hibernate5.HibernateTransactionManager;
  import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
  import org.springframework.orm.jpa.JpaTransactionManager;
  import org.springframework.orm.jpa.JpaVendorAdapter;
  import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  import org.springframework.transaction.PlatformTransactionManager;
  
  @SpringBootApplication(scanBasePackages = {&quot;com.draconia.testWeb.controller&quot;})
  public class TestWebApplication
  {
      
      @Bean
      public DataSource getDatasource()
      {
          BasicDataSource objDatasource = new BasicDataSource();
          
          objDatasource.setDriverClassName(&quot;com.mysql.jdbc.Driver&quot;);
          objDatasource.setUrl(&quot;jdbc:mysql://localhost:3306/Test&quot;);
          objDatasource.setUsername(&quot;root&quot;);
          objDatasource.setPassword(&quot;R3g1n@ M1lL$ 1$ My Qu3eN!&quot;);
          
          return(objDatasource);
      }
      
      @Bean
      public LocalContainerEntityManagerFactoryBean getEntityManagerFactory()
      {
            LocalContainerEntityManagerFactoryBean objEntityManager = new LocalContainerEntityManagerFactoryBean();
            
            objEntityManager.setDataSource(getDatasource());
            objEntityManager.setPackagesToScan(new String[] { &quot;net.draconia.testWeb.beans&quot; });
  
            JpaVendorAdapter objVendorAdapter = new HibernateJpaVendorAdapter();
            objEntityManager.setJpaVendorAdapter(objVendorAdapter);
            objEntityManager.setJpaProperties(getHibernateProperties());
  
            return(objEntityManager);
     }
      
      protected Properties getHibernateProperties()
      {
          Properties objHibernateProperties = new Properties();
          
          objHibernateProperties.setProperty(&quot;hibernate.hbm2ddl.auto&quot;, &quot;create-drop&quot;);
          objHibernateProperties.setProperty(&quot;hibernate.dialect&quot;, &quot;org.hibernate.dialect.MySQLDialect&quot;);
          
          return(objHibernateProperties);
      }
      
      @Bean
      public JpaTransactionManager getHibernateTransactionManager()
      {
          JpaTransactionManager objTransactionManager = new JpaTransactionManager();
          
          objTransactionManager.setEntityManagerFactory(getEntityManagerFactory().getObject());
          
          return(objTransactionManager);
      }
      
      public static void main(String[] args)
      {
          SpringApplication.run(TestWebApplication.class, args);
      }
  }
  </code></pre>
  <p>, the entity bean:</p>
  <pre><code>package net.draconia.testWeb.beans;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity(name = &quot;Books&quot;)
  public class Book
  {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer miId;
      
      @Column(columnDefinition = &quot;varchar(200) not null&quot;, insertable = true, length = 200, name = &quot;BookName&quot;, nullable = false, table = &quot;Books&quot;, unique = false, updatable = true)
      private String msBookName;
      
      @Column(columnDefinition = &quot;varchar(100) not null&quot;, insertable = true, length = 100, name=&quot;Author&quot;, nullable = false, table = &quot;Books&quot;, unique = false, updatable = true)
      private String msAuthor;
      
      public String getAuthor()
      {
          if(msAuthor == null)
              msAuthor = &quot;&quot;;
          
          return(msAuthor);
      }
      
      public String getBookName()
      {
          if(msBookName == null)
              msBookName = &quot;&quot;;
          
          return(msBookName);
      }
      
      public int getId()
      {
          if(miId == null)
              miId = 0;
          
          return(miId);
      }
      
      public void setAuthor(final String sAuthor)
      {
          if(sAuthor == null)
              msAuthor = &quot;&quot;;
          else
              msAuthor = sAuthor;
      }
      
      public void setBookName(final String sBookName)
      {
          if(sBookName == null)
              msBookName = &quot;&quot;;
          else
              msBookName = sBookName;
      }
      
      public void setId(final Integer iId)
      {
          if(iId == null)
              miId = 0;
          else
              miId = iId;
      }
  }
  </code></pre>
  <p>, the DAOConcrete class (the interface is just one method which is logical but if you want I'll post that too):</p>
  <pre><code>package net.draconia.testWeb.dao;
  
  import java.util.List;
  
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  
  import org.springframework.beans.factory.annotation.Autowired;
  
  import org.springframework.stereotype.Repository;
  
  import net.draconia.testWeb.beans.Book;
  
  @Repository(&quot;bookDAO&quot;)
  public class BookDAOImpl implements BookDAO
  {
      @Autowired
      private EntityManagerFactory mObjEntityManagerFactory;
      
      public List&lt;Book&gt; getAllBooks()
      {
          EntityManager objEntityManager = getEntityManagerFactory().createEntityManager();
          List&lt;Book&gt; lstBooks = objEntityManager.createQuery(&quot;from Books&quot;, Book.class).getResultList();
          
          return(lstBooks);
      }
      
      protected EntityManagerFactory getEntityManagerFactory()
      {
          return(mObjEntityManagerFactory);
      }
  }
  </code></pre>
  <p>, and the Controller class for the REST endpoints/MVC Controller:</p>
  <pre><code>package net.draconia.testWeb.controllers;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  
  import net.draconia.testWeb.beans.Book;
  import net.draconia.testWeb.dao.BookDAO;
  
  @Controller
  public class TestController
  {
      @Autowired
      private BookDAO mObjDAO;
      
      @GetMapping(&quot;/Books&quot;)
      public List&lt;Book&gt; getBooks()
      {
          return(getDAO().getAllBooks());
      }
      
      protected BookDAO getDAO()
      {
          return(mObjDAO);
      }
  }
  </code></pre>
  <p>The POM file is here just for completeness but I don't think it's necessarily a problem unless I'm missing a dependency:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&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;2.7.1&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      
      &lt;groupId&gt;net.draconia&lt;/groupId&gt;
      &lt;artifactId&gt;testWeb&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;testWeb&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
      
      &lt;properties&gt;
          &lt;hibernate.version&gt;6.1.0.Final&lt;/hibernate.version&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
          &lt;mysql.version&gt;8.0.29&lt;/mysql.version&gt;
          &lt;spring.version&gt;5.3.2&lt;/spring.version&gt;
      &lt;/properties&gt;
      
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
              &lt;version&gt;2.13.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jakarta.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;jakarta.persistence-api&lt;/artifactId&gt;
              &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;javax.persistence-api&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;${mysql.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-dbcp2&lt;/artifactId&gt;
              &lt;version&gt;2.9.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate.orm&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  <p>If you'll note, i'm including a dependency for the Jackson library because the list of books should return as a JSON object.  I don't think that's a poblem but just saying - and I could probably have remoed that for this but then when it runs, the list of books would be unintelligible to me getting a response when/if it worked.  What am I doing wrong???</p>