我有IntegrationFlow
我称之为 HTTP 端点的地方:
@Bean
public IntegrationFlow getInformationFlow(RestTemplate restTemplate) {
return IntegrationFlows.from(GET_RESPONSE_ENTITY)
.handle(Http
.outboundGateway(url + "/application/{code}", restTemplate)
.httpMethod(GET)
.uriVariable("code", "payload")
.expectedResponseType(new ParameterizedTypeReference<ResponseEntity<Information>>() {
})
).get();
}
此流程在getInformation
被调用时执行,这要归功于Gateway
@MessagingGateway
public interface MyGateway {
@Gateway(requestChannel = GET_RESPONSE_ENTITY)
ResponseEntity<Information> getInformation(String code);
}
上面的代码抛出以下异常:
Caused by: org.springframework.http.converter.HttpMessageConversionException:
Type definition error: [simple type, class org.springframework.http.ResponseEntity];
nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Cannot construct instance of `org.springframework.http.ResponseEntity`
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
杰克逊试图反序列化成ResponseEntity
而不是Information
类
我的目标是首先检查状态代码,并可选择检查Information
字段
是否可以从注释的方法返回 ResponseEntity @Gateway
?