问题描述
OepnFeign 客户端使用 WebFlux 时遇到错误
- FeignClient:
@GetMapping("/{deviceId}/test")
Mono<R> test(@PathVariable(value = "deviceId") String deviceId);
调用后报错:
feign.codec.DecodeException: Type definition error: [simple type, class reactor.core.publisher.Mono]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `reactor.core.publisher.Mono` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (PushbackInputStream); line: 1, column: 1]
at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:182) ~[feign-core-10.4.0.jar:na]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
reactor.core.publisher.Mono.flatMap
org.springframework.web.reactive.result.method.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:137)
Error has been observed at the following site(s):
解决办法:
查看 Spring 官网文档,发现目前(2020-12-17)OpenFeign 暂不支持 WebFlux :
https://docs.spring.io/spring-cloud-openfeign/docs/2.2.5.RELEASE/reference/html/#reactive-support
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于