0
我設計所需要的REST服務與JERSEY 1.5,使用像宣稱的接口:使用接口的Jersey 1.x REST。如何
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public IMyDTO doIt(ICustomer customer) {
return MySupport.createDTO(customer);
}
如果我試圖調用這個服務,使用JERSEY 1.5客戶端API,出現下列錯誤:
不能構造test.ICustomer,問題的實例:抽象類型要麼需要被映射到具體類型,具有自定義解串器,或用附加的類型信息被實例化
目前我通過客戶端指定這樣的參數:
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(restResource);
ClientResponse response = webResource.path(restResourcePath)
.type(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, customer);
if (response != null) {
if (response.hasEntity()) {
result = response.getEntity(IMytDTO.class);
}
....
。 The ICustomer and IMyDTO are java interfaces without any jackson annotation。該實現也沒有傑克遜註釋。
我的問題:如何使用REST服務(客戶端)來序列化對象?
我不會改變Java接口,並使用在服務和客戶端的實現......
瞭如何註冊定製的(反)澤西串行? –
你應該能夠配置澤西在春季配置中使用傑克遜:http://stackoverflow.com/questions/12883287/how-to-easily-use-jackson-for-jersey –