我正在尝试获取 java.util.List 作为来自 cxf REST Web 服务的响应。我尝试过使用 WebClient 类的方法 postObjectGetCollection 方法,但没有运气。我得到 - org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No message body reader has found for class: interface java.util.Collection, ContentType: application/json。
以下是我的客户代码-
String mediaType = "application/json";
if (url != null) {
List<DataTypeDTO> resultdtos = new ArrayList<DataTypeDTO>();
WebClient client = WebClient.create(url);
client = client.accept(mediaType).type(mediaType).path(uri);
resultdtos = (List<DataTypeDTO>)client.getCollection(DataTypeDTO.class);
System.out.println(resultdtos);
}
如果我缺少任何配置或其他内容,请帮助我。