org.codehaus.jackson.map.JsonMappingException

当一个类的所有属性都没有getter时(所有属性都是public的)jackson 序列化时会抛出如下异常: 
org.codehaus.jackson.map.JsonMappingException: No serializer found for class log.LogUser and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: log.Log["owners"]->java.util.ArrayList[0]) 
解决方法为:在每个public属性上使用注解@JsonProperty 。

如果是spring 的话 model。clear 即可,将不必要的东西 去除掉

猜你喜欢

转载自woshixushigang.iteye.com/blog/1554453