我正在使用Play Framework
和morphia
来部署REST
服务。我在Object
响应中传递Generic Jackson
时收到以下错误
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class java.lang.Object and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: common.ResponseStatusEntity["data"]->entities.Trainer["appointmentNotificaiton"]->entities.notificaitons.AppointmentNotificaiton["data"])
如何在play框架中禁用Serializer验证?
问题是Object
没有任何属性,默认情况下Jackson
不接受它。要禁用它,您需要配置ObjectMapper
,如下所示:
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
但马赫更好的是返回某种SUCCESS
对象,明确告诉一切都是OK
。