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.

  1. oracle java 8.
  2. "org.springframework.boot:spring-boot-gradle-plugin:1.2.3.release",
  3. "org.springframework.boot:spring-boot-starter-web",
  4. "org.springframework.boot:spring-boot-starter-actuator",
  5. 'org.springframework.boot:spring-boot-starter-mail',
  6. "org.springframework.boot:spring-boot-starter-thymeleaf",
  7. "org.springframework.boot:spring-boot-starter-security",
  8. "org.springframework.security.oauth:spring-security-oauth2:2.0.0.rc2",
  9. "org.springframework.boot:spring-boot-starter-data-jpa",
  10. "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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -