Spring boot: How to configure pagination on a @RepositoryRestResource? -
i've looked @ both this , this question. have still not been able setup paging repository method. not sure if i'm affected bug or not writing correctly. i'm asking if provide example of how implement paging on repository method gets exported through @repositoryrestresource annotation?
my attempt @ achieving pagination
@repositoryrestresource(collectionresourcerel = "users", path = "users") public interface userrepository extends jparepository<user, long> { page<user> findbyusergroup(@param("usergroup") string usergroup, @param("page") pageable pageable); }
the error message generated code
offending method public abstract org.springframework.data.domain.page com.project.repository.userrepository.findbyusergroup(java.lang.string,java.awt.print.pageable)
i've tried removing method param pageable resulted in error:
caused by: java.lang.illegalargumentexception: either use @param on parameters except pageable , sort typed once, or none @ all!
dependencies i'm using in project.
- oracle java 8.
- "org.springframework.boot:spring-boot-gradle-plugin:1.2.3.release",
- "org.springframework.boot:spring-boot-starter-web",
- "org.springframework.boot:spring-boot-starter-actuator",
- 'org.springframework.boot:spring-boot-starter-mail',
- "org.springframework.boot:spring-boot-starter-thymeleaf",
- "org.springframework.boot:spring-boot-starter-security",
- "org.springframework.security.oauth:spring-security-oauth2:2.0.0.rc2",
- "org.springframework.boot:spring-boot-starter-data-jpa",
- "org.springframework.boot:spring-boot-starter-data-rest",
any appreciated.
update: final solution
adding reference else wondering how this. main difference had make sure import right pageable
object noted in chosen answer.
@repositoryrestresource(collectionresourcerel = "users", path = "users") public interface userrepository extends jparepository<user, long> { page<user> findbyusergroup(@param("usergroup") string usergroup, pageable pageable); }
you using pageable class wrong package: java.awt.print.pageable
. should using org.springframework.data.domain.pageable
Comments
Post a Comment