我是使用JPA的新手,我正在阅读在线教程,它们都是从JPARespository扩展而来的,如下所示
从本页
https://www.callicoder.com/spring-boot-jpa-hibernate-postgresql-restful-crud-api-example/
package com.example.postgresdemo.repository;
import com.example.postgresdemo.model.Answer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface AnswerRepository extends JpaRepository<Answer, Long> {
List<Answer> findByQuestionId(Long questionId);
}
但是在我的项目中,Eclipse抱怨如下
The type JpaRepository<Property,Long> cannot be the superclass of PropertyRepository; a superclass must be a class
下面是我的课
package realestate.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import realestate.model.Property;
import java.util.List;
@Repository
public class PropertyRepository extends JpaRepository<Property, Long> {
}
1条答案
按热度按时间shyt4zoc1#
基本上,JPA储存库是接口。
在代码中,您声明了一个类,并使用接口扩展了它。类可以实现接口,但不能扩展接口。
因此,请将Class声明更改为如下所示的接口。
至