I'm trying to use dynamically feign. But i have many issues when converting the response from RequestMapping.
Controller.java :
@RequestMapping("/users")
public ResponseEntity<List<User>> sendUsers
MyFeignClient.java :
public interface MyFeignClient {
@RequestLine(value="GET /api/users")
ResponseEntity<List<User>> getUsers();}
MainClass.java :
MyFeignClient callService = Feign.builder()
.encoder(new Encoder.Default())
.decoder(new Decoder.Default())
.requestInterceptor(new FeignConfig(props).getJwtRequestInterceptor())
.target(MyFeignClient.class, "http://localhost:8710");
And then :
ResponseEntity<List<User>> txnPool = callService.getUsers();
But i have the following error :
feign.codec.DecodeException User is not a type supported by this decoder
How can i fix that?
I resolved it by using JacksonEncoder and JacksonDecoder (from the Netflix Jackson library):
MyFeignClient callService = Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.requestInterceptor(new FeignConfig(props).getJwtRequestInterceptor())
.target(MyFeignClient.class, "http://localhost:8710");
i also added @Headers("Content-Type: application/json") to my Feign Interface
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With