解决org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON...问题

报错如下:

Resolved [org.springframework.http.converter.HttpMessageNotWritableException: 
Could not write JSON: (was java.lang.NullPointerException); 
nested exception is com.fasterxml.jackson.databind.JsonMappingException: 
(was java.lang.NullPointerException) (through reference chain: 
com.edu.server.pojo.RespBean["obj"]->com.edu.server.pojo.
User["authorities"])]

解决办法:
项目采用springsecurity做权限控制,出现了无法写入JSON的错误,错误发生在Ueser类的getAuthorities()方法,在该方法上加上@JsonIgnore注解即可。
解决org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON...问题_第1张图片

你可能感兴趣的:(spring,boot,json)