存储库中的切片`返回类型与PagingAndSortingRepository不兼容`

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

我创建了返回类型 Slice 的 findAll 函数,然后收到此错误:

The return type is incompatible with PagingAndSortingRepository<Book,Long>.findAll(Pageable)
这是我在存储库中的代码:

import org.springframework.data.domain.Slice;

@SuppressWarnings("unused")
@Repository
public interface BookRepository extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> {
    Slice<Book> findAll(Pageable pageable);
}

我在这里做错了什么?

java spring jpa
2个回答
0
投票

来自M的回答。 Deinum 在评论中

该方法已在 JpaRepository 中可用,并返回一个页面,您>无法使用其他返回类型重新定义它,并且您实际上不需要它>因为它已经存在。


0
投票

“列表findAll(可分页可分页);”我使用了这个语句,然后出现错误 - “ - 返回类型与 PagingAndSortingRepository.findAll(Pageable) 不兼容 “然后我使用了“Page findAll(Pageable pageable);”并且我的问题正确解决了。

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