PagingAndSortingRepository无法解析

问题描述 投票:0回答:6

我尝试使用

Spring Data
中的 PagingAndSortingRepository

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

public interface StudentRepository extends JpaRepository<Student, Integer> {}

但是我收到此错误:

org.springframework.data.repository.PagingAndSortingRepository
无法解决

我的代码有什么问题以及如何修复它?

spring spring-boot spring-data-jpa spring-data repository
6个回答
10
投票

这个解决了我的问题

摇篮

// https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '2.0.1.RELEASE'

Maven

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>

6
投票

我解决了这个问题,包括

spring-data-commons
,其中包括
PagingAndSortingRepository

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>


1
投票

删除 ~.m2/org/springframework.data 文件夹并更新 maven 项目。


0
投票

确保 jar 已安装。

 mvn clean dependency:tree

2)这对我来说是这样的:


0
投票

如果您有

<artifactId>spring-data-commons</artifactId>
依赖性并且
<artifactId>spring-data-jpa</artifactId>
两者都有,那么就会出现此问题。

删除

<artifactId>spring-data-commons</artifactId>
依赖项。


0
投票

您使用的是JPA Repository 但发生的情况是,maven 要么没有更新所有必需的文件。所以为了获取所需的所有文件,我们可以更新 maven,以便它可以获取所有文件

或者我们可以 将扩展 JPA Repository 更改为 CRUD Repository,然后将其更改为 JPA Repository 它的作用是,它首先访问 CRUD 所需的所有文件,并且它适用于 JPA 存储库

这对我有用

© www.soinside.com 2019 - 2024. All rights reserved.