Hello,
After changing from jackson:
spring.http.converters.preferred-json-mapper=jackson
to gson:
spring.http.converters.preferred-json-mapper=gson
The endpoint below stopped working and started to return {}
@GetMapping
@ApiPageable
public Page<Foobar> getFoobaz() {
return service.getFoobaz();
}
The endpoint only works if I add the annotation below:
@Configuration
@EnableWebMvc /* <-- Annotation added */
public class WebMvcConfig implements WebMvcConfigurer {
There is another issue related with this behavior: https://github.com/spring-projects/spring-framework/issues/24234
And a StackOverflow question: https://stackoverflow.com/questions/51387999/spring-data-jpa-page-and-json-with-gson
Expected behavior: returning paginated objects, same as Jackson does.
Versions used:
spring-boot:2.2.0.RELEASE
spring-webmvc:5.2.0.RELEASE
Comment From: dan1els
I think the problem is that gson expects class with default ctor, but getting Page interface.
That's the error I get
Unable to invoke no-args constructor for org.springframework.data.domain.Page<UserSearchData>. Registering an InstanceCreator with Gson for this type may fix this problem
Comment From: snicoll
The above is related to Spring Boot and Spring Data. Neither are handled here so if you're still affected, I'd start by reporting an issue to the Spring Data REST project.