spring.data.rest.max-page-size does not seem to work?

 ̄綄美尐妖づ 提交于 2019-12-04 10:06:32

This was somewhat of a gotcha for me. I think the easiest solution is using configuration properties instead of code. So this is what I found and what worked for me.

If you are using a Pageable in a @RestController then you can set it using property spring.data.web.pageable.max-page-size.

If you are using a Pageable in a @RepositoryRestResource then you can set it using property spring.data.rest.max-page-size.

I just tried that - I think your expectation is correct - it sets the maximum limit of a page.

But I think your property name is incorrect - try this:

spring.data.rest.maxPageSize=10

See here for documentation: http://docs.spring.io/spring-data/rest/docs/2.4.0.RELEASE/reference/html/#_changing_other_spring_data_rest_properties

Worked for me only with config enforced through code:

@Configuration
public class CustomizedRestMvcConfiguration extends RepositoryRestMvcConfiguration
{
  @Override
  public RepositoryRestConfiguration config() {
    RepositoryRestConfiguration config = super.config();
    config.setMaxPageSize(10000);
    return config;
  }
}

http://docs.spring.io/spring-data/rest/docs/2.4.0.RELEASE/reference/html/#_changing_the_base_uri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!