IllegalArgumentException: At least one JPA metamodel must be present

Solution 1:

You have added

<dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

in your pom.xml.

Spring boot will try automatically create an entity factory for JPA, but you do not have defined anything regarding JPA models.

Try removing it in order to test what have you done so far.

Afterwards you can check a tutorial using spring-data-starter-jpa like this guy

Solution 2:

I've fixed it by setting newer version of Hibernate.

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
         <exclusions>
             <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.10.Final</version>
    </dependency>

You can find a fully working example here: https://github.com/zobarov/ptc-task-executor

Solution 3:

You can also disable Spring Data JPA's repository support by excluding the following auto configuration class (e.g. in your @EnableAutoConfiguration or @SpringBootApplication annotation)

org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration

For example:

@EnableAutoConfiguration(exclude = JpaRepositoriesAutoConfiguration.class)

Solution 4:

This worked for me.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
     <exclusions>
         <exclusion>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.2.10.Final</version>
</dependency>