SpringBoot异常
切换到Gson后,使用SpringBoot搭建的Web项目的接口直接请求不了了。报错类似:
org.springframework.http.converter.HttpMessageNotWritableException
因为SpringBoot默认的Mapper是Jackson解析,我们切换为了Gson作为返回对象后,Jackson解析不了了。
解决方案:
application.properties里面添加:
#Preferred JSON mapper to use for HTTP message conversion
spring.mvc.converters.preferred-json-mapper=gson