Springboot JPA Repository

76 views Asked by At

I am creating a JPA Repository in Springboot.

import org.springframework.data.jpa.repository.JpaRepository;


public class UserRepository extends JPARepository<User, Long>{
    
}

The error that I am getting is that I cannot resolve the JPA Repository library.

In Maven, on pom.xml, I put

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

I did maven clean, validate, and install. In the pom.xml file, I am not getting any errors. However, on my repository code, I am getting JPARepository not found despite the fact I imported "import org.springframework.data.jpa.repository.JpaRepository."

1

There are 1 answers

0
ozkanpakdil On

Use interface instead of class, like below

public interface UserRepository extends JPARepository<User, Long>{
    
}