1. 程式人生 > >org.codehaus.jackson.map.JsonMappingException: No serializer found for class

org.codehaus.jackson.map.JsonMappingException: No serializer found for class

出處:http://www.baeldung.com/jackson-jsonmappingexception

支援原創

通常這個異常是沒有給屬性新增setter/getter

方法1

加上get/set

方法2

修改屬性可見性

2.1  mapper級別

objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);

2.2 class 級別

@JsonAutoDetect(fieldVisibility = Visibility.ANY) public class MyDtoNoAccessors { ... } HAVE FUN!