【发布时间】:2021-08-17 17:01:15
【问题描述】:
我正在使用 JpaRepository,这是我的代码
public Interface EmpRepository extends JpaRepository<Employee, Integer> {}
class EmployeeServicImpl {
private EmpRepository empRepository;
@Autowired
EmployeeServicImpl (EmpRepository theRepository) {
this.empRepository = theRepository;
}
}
在我的pom.xml 中添加了以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
在启动应用程序时,从类加载器解析 bean 声明的构造函数:NoClassDeffFoundError : /org/springframework/data/jpa/repository/Repository
【问题讨论】:
-
接口
Repository确实在不同的包中:docs.spring.io/spring-data/commons/docs/current/api/org/… -
请确保您的导入正确。如果这没有帮助,请发布更多您的
pom.xml和您的代码。 -
发布完整的 pom.xml
标签: spring-boot spring-data-jpa