Support Spring Data Pageable in Feign Client
See original GitHub issueI am using Feign for requesting a MicroService who support Spring Data Pageable functionnality.
This is my FeignClient Interface :
@FeignClient(FeignServiceId.SERVICE_ID)
@RequestMapping(value = "api/document")
public interface DocumentApi {
@RequestMapping(method = RequestMethod.GET, value = "user/{userLogin}")
Page<DeclarationDT> getDeclarationsByUserLogin(@PathVariable("userLogin") String userLogin, Pageable pageable);
}
When i make a call to the getDeclarationsByUserLogin, Feign do a POST request whereas i specify RequestMethod.GET.
I think this is due to the fact that Feign not support the Spring Data Pageable functionnality.
Is it possible to implement support for this feature ?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:18
- Comments:32 (11 by maintainers)
Top Results From Across the Web
Spring Data Pageable not supported as RequestParam in ...
I think your code doesn't work because you are using @RequestParam annotation for Pageable parameter in your Feign method.
Read more >How to use pagination in Spring Boot — OpenFeign - Medium
Lets create simple page custom object to get page data source above. and also need to create custom config for Feign Interface that...
Read more >FeignClient: How to use Pageable? #2672 - GitHub
I am build a MicroService who support Spring Data Pageable functionnality. like this: @PostMapping("search") @OverRide public Result<Page> ...
Read more >Spring Cloud OpenFeign
Spring Data Support ; 1.21. ... This project provides OpenFeign integrations for Spring Boot apps through ... Feign is a declarative web service...
Read more >how to pass Spring Pageable to FeignClient-Spring MVC
How am I supposed to pass an unpaged but sorted Pageable to a Spring JPA repository? How to pass List<String> in post method...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This bugged me as well, and I wanted to use the same method signature on the client (feign) as on the server side, i.e.
Page<T>andPageablein the feign interface.I’ve come up with the following solution:
Pageable support in Feign
This encoder can be added to your current encoder by composition:
Sample configuration
Page<T>supportThis is a simple Jackson mapper issue, so it can be solved by adding a mixin for Page<T>
Register (
.mixIn(Page.class, PageMixIn.class)) the MixInMaybe that helps someone 😃
Works for me. Thanks a lot @IsNull !
Pageablemust be annotated with@RequestBody. Looks like FeignEncoderis only applied for body parameters.My Jackson configuration for Spring Boot: