Jakarta ee 如何制作日食';s moxy marshall HashMap<;字符串,字符串>;?
当jersey应用程序中的方法返回HashMap时,会出现以下异常Jakarta ee 如何制作日食';s moxy marshall HashMap<;字符串,字符串>;?,jakarta-ee,jersey,moxy,Jakarta Ee,Jersey,Moxy,当jersey应用程序中的方法返回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 [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;
}
@PUT
@路径(“/subscriptions/{id}”)
@生成(“应用程序/json”)
公共地图更新订阅(@PathParam(“id”)int-id){
Map response=newhashmap();
响应。放置(“状态”、“确定”);
返回响应;
}
Moxy在我的应用程序中与POJO配合得很好。所以,我猜它足够聪明来处理HashMap 注意:我是专家组的负责人和成员
MOXyJsonProvider
当前不支持根级别的Map
。我刚刚检查了EclipseLink 2.5.2和2.6.0流的修复程序,以便isReadable
/isWriteable
将为这些类型返回false,这样MOXy就不会被选为此用例的JSON绑定提供程序。从2013年10月11日开始,您可以从以下链接下载夜间版本:
Map
的一流支持: