首页 > 解决方案 > 加装手柄 助焊剂返回型

问题描述

如何在改造中处理通量返回类型?

端点API

public interface DataEndPointApi {
   @GET( "ap1/v3/data")
   Flux<Data> getAllData(@Query( "dataType") String dataType);
}

RetroRestAdapter

@Autowired
private ObjectMapper objectMapper;

RestAdapter retrofit = new RestAdapter.Builder()
         .setEndpoint( "http://localhost:8080" )
         .setConverter( new JacksonConverter( this.objectMapper ) )         
         .build();

呼叫者

DatasourceEndPointApi datasourceEndPointApi;
Flux<Data> dataFlux = this.dataEndPointApi.getAllData( "GREETING" );

我得到以下错误

错误

retrofit.RetrofitError: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `reactor.core.publisher.Flux` (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: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 1]
    at retrofit.RetrofitError.conversionError(RetrofitError.java:33)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
    at com.sun.proxy.$Proxy153.getAllDatasource(Unknown Source)
    at 

那么,如何在 Retrofit 中处理 Flux 返回类型?

标签: javaspring-bootretrofitretrofit2flux

解决方案


推荐阅读