Reputation: 89
I am trying to use JpaRepository but I am getting this error "jparepository cannot be resolved to a type."
My maven dependency is
` 4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.2.RELEASE com.example accessing-data-jpa 0.0.1-SNAPSHOT accessing-data-jpa Demo project for Spring Boot
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
`
My student class is
package Repositry;
public interface Student_Repo extends JpaRepositry {
}
Please let me know what I have done wrong
Upvotes: 2
Views: 5375
Reputation: 429
This error might occur
As spelling error
If you commented out the Jpa dependency in pom.xml or didn't add it in the first place.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
HTH
Upvotes: 0
Reputation: 15878
Typo here.
It is JpaRepository
not JpaRepositry
Also it expects 2 parameters.
Entity class
Type of primary key field (Integer/Long)
Like below.
Student_Repo extends JpaRepository<Student,Long>
Upvotes: 2