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

huangapple go评论79阅读模式
英文:

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&lt;Book,Long&gt;.findAll(Pageable)
Here is my code in repository:

import org.springframework.data.domain.Slice;

@SuppressWarnings(&quot;unused&quot;)
@Repository
public interface BookRepository extends JpaRepository&lt;Book, Long&gt;, JpaSpecificationExecutor&lt;Book&gt; {
    Slice&lt;Book&gt; findAll(Pageable pageable);
}

What did I do wrong here?

答案1

得分: 0

[M. Deinum](https://stackoverflow.com/users/2696260/m-deinum) 在评论中的回答:
&gt; 这个方法已经在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.

huangapple
  • 本文由 发表于 2023年6月26日 15:52:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554614.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定