spring jpa - At least one JPA metamodel must be present*

Spring does not find any JPA Entities, so no JPA Meta Model is created, that is why you face the exception.

The cause of this problem may be a wrong persistence-api version on your class path.

You are using

<dependency> 
    <groupId>javax.persistence</groupId> 
    <artifactId>persistence-api</artifactId> 
    <version>1.0.2</version> 
</dependency> 

but I am pretty shure your spring version uses persistence-api version 2.

Could it be, you are using @Entity annotation from version 1 ? At runtime spring uses version 2, and this is searching for Entites using @Entity from version 2 only !

Remove the dependencies

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
</dependency>    
<dependency>
   <groupId>org.springframework.data</groupId>
   <artifactId>spring-data-jpa</artifactId>
   <version>1.11.1.RELEASE</version>
</dependency>

Instead add

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

This will give you all JPA dependencies in the right version.


I solved it by adding 2 annotations

@EnableAutoConfiguration
@EntityScan(basePackages = { "com.wt.rds" })

and my dependency was in gradle

compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.4.RELEASE'