我已經配置這樣的JAXRS客戶端:JAXRS客戶端無法找到郵件正文作家
<jaxrs:client id="opaRestProxy" name="opaRestProxy"
address="${endpoint}" serviceClass="com.test.RestProxy"
inheritHeaders="true" threadSafe="true">
<jaxrs:headers>
<entry key="Accept" value="application/json" />
<entry key="Content-Type" value="application/json" />
</jaxrs:headers>
</jaxrs:client>
但是,當我發送一個請求,我得到以下異常:
Caused by: org.apache.cxf.interceptor.Fault: .No message body writer has been found for class : class com.test.RequestObject, ContentType : application/json.
at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:646)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:527)
... 47 more
我RestProxy類看起來像這樣:
@Component
public interface RestProxy {
@POST
@Path("/getSomething")
String getSomething(RequestObject RequestObject);
}
您是否使用了特定的JSON庫?這聽起來像你沒有配置提供商。 – Patrick