繁体   English   中英

如何在Play框架中禁用序列化?

[英]How to disable Serialization in play framework?

我正在使用Play Frameworkmorphia来部署REST服务。 我像Jackson响应那样传递通用Object时遇到以下错误

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"])

如何在播放框架中禁用序列化程序验证?

问题是Object没有任何属性,而Jackson默认情况下不接受它。 要禁用它,您需要配置ObjectMapper如下所示:

ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

但是更好的方法是返回某种SUCCESS对象,该对象明确告诉一切OK

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM