PagingAndSortingRepositoryではなくJpaRepositoryを使用してオブジェクトのページを返すメソッドを実装するにはどうすればよいですか?jpaを使用したスプリングブートによるページ設定
マイリポジトリ
public interface GroupRepository extends JpaRepository<Group, Long> {
@Query(value = "SELECT g FROM Group")
Page<Group> listAllByPage(Pageable pageable);
}
私のサービスの実装:
@Override
public
Page<Group> findGroupesByPagination(Pageable pageable) {
return groupeRepository.listAllByPage(pageable);
}
は、私の残りのコントローラの方法:
@RequestMapping(value="/groups", method = RequestMethod.GET)
public @ResponseBody Page<Group> list(Pageable pageable){
Page<Group> groupes = groupeServiceImpl.findGroupesByPagination(pageable);
return groupes;
}
は最後に、私はこのエラーを得た:
Error creating bean with name 'groupServiceImpl': Unsatisfied dependency expressed through field 'groupeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groupRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract org.springframework.data.domain.Page rimtrack.org.repository.GroupRepository.listAllByPage(org.springframework.data.domain.Pageable)!
選択クエリで「グループ」の後に「G」を追加してください:「グループGからGを選択し、」 – Cepr0
はいおかげで、これが正しい答え – Elouafi
である私を+1することを忘れないでください。コメント;) – Cepr0