当我的球衣应用程序中的方法返回 HashMap 时,出现以下异常
[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: Exception [EclipseLink-25007] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor for class java.util.HashMap was not found in the project. For JAXB, if the JAXBContext was bootstrapped using TypeMappingInfo[] you must call a marshal method that accepts TypeMappingInfo as an input parameter.]
有问题的方法是:
@PUT
@Path("/subscriptions/{id}")
@Produces("application/json")
public Map<String, String> updateSubscription(@PathParam("id") int id) {
Map<String, String> response = new HashMap<String, String>();
response.put("status", "ok");
return response;
}
Moxy 在我的应用程序中与 POJO 配合得很好。所以,我猜它足够聪明来处理 HashMap。