gpt4 book ai didi

java - 来自 openfeign 和 Observable 的 @FeignClient 导致 fasterxml.jackson.databind.exc.InvalidDefinitionException

转载 作者:行者123 更新时间:2023-11-30 10:03:51 26 4
gpt4 key购买 nike

我有一个带有以下假客户的项目

@FeignClient(name = "name", url = "${tokenService}")
public interface TokenService {
@RequestMapping(path = "/SLJsonWebTokenWrapper/token/wrap", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
Observable<Token> getToken(@RequestHeader("externalSystemCode") String systemCode,
@RequestBody TokenRequest tokenRequest);
}

和以下依赖

org.springframework.cloud:spring-cloud-starter-feign

一切正常。当我将我的项目更新到 Spring Boot 2(并使用 org.springframework.cloud:spring-cloud-starter-openfeign)时,对此服务的请求失败并出现异常

c.f.j.d.e.InvalidDefinitionException: Cannot construct instance of 
`rx.Observable` (no Creators, like default construct, exist): cannot
deserialize from Object value (no delegate- or property-based Creator)
at [Source: (ByteArrayInputStream); line: 1, column: 2]
at c.f.j.d.e.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at c.f.j.d.DeserializationContext.reportBadDefinition(DeserializationContext.java:1452)
at c.f.j.d.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1028)
at c.f.j.d.d.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1297)
at c.f.j.d.d.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at c.f.j.d.d.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at c.f.j.d.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at c.f.j.d.ObjectMapper.readValue(ObjectMapper.java:3084)
... 1 frames excluded
... 99 common frames omitted
Wrapped by: o.s.h.c.HttpMessageConversionException: Type definition
error: [simple type, class rx.Observable]; nested exception is
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot
construct instance of `rx.Observable` (no Creators, like default
construct, exist): cannot deserialize from Object value (no delegate-
or property-based Creator)
at [Source: (ByteArrayInputStream); line: 1, column: 2]
at o.s.h.c.j.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:240)
at o.s.h.c.j.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:225)
... 3 frames excluded
at f.o.OptionalDecoder.decode(OptionalDecoder.java:36)
at f.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:170)
... 93 common frames omitted
Wrapped by: f.c.DecodeException: Type definition error: [simple type, class rx.Observable]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `rx.Observable` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (ByteArrayInputStream); line: 1, column: 2]

我该如何解决?

附言这个问题类似于Spring cloud netflix and HystrixObservable --> JsonMappingException , 虽然没有答案

最佳答案

添加这个选项解决了我的问题

feign.hystrix.enabled: true

关于java - 来自 openfeign 和 Observable 的 @FeignClient 导致 fasterxml.jackson.databind.exc.InvalidDefinitionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56183536/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com