英文:
Slice in repository `The return type is incompatible with PagingAndSortingRepository`
问题
我已经创建了返回类型为Slice的findAll函数,然后遇到了这个错误:
返回类型与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);
}
我在这里做错了什么?
英文:
I have create findAll function with return type Slice then got this error:
The return type is incompatible with PagingAndSortingRepository<Book,Long>.findAll(Pageable)
Here is my code in repository:
import org.springframework.data.domain.Slice;
@SuppressWarnings("unused")
@Repository
public interface BookRepository extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> {
Slice<Book> findAll(Pageable pageable);
}
What did I do wrong here?
答案1
得分: 0
[M. Deinum](https://stackoverflow.com/users/2696260/m-deinum) 在评论中的回答:
> 这个方法已经在JpaRepository中可用,它返回一个Page,你不能重新定义它的返回类型,而且你实际上也不需要它,因为它已经存在。
英文:
Answer from M. Deinum in comment
>That method is already available in the JpaRepository and returns a Page you >cannot redifine it with another return type and you don't actually need it >because it is already there.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论