SpringBoot 项目 Could not find acceptable representation 解决方法

完整信息:

WARN 20144 — [0.0-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]

原因:

Controller 方法返回的对象没有 get 方法,无法将对象转换为 JSON

解决方法:

添加 get 方法,有 get 方法的属性才会转换称 JSON

可以使用 lombok 库在类上注解 @Data 或者 @Getter

猜你喜欢

转载自blog.csdn.net/Cey_Tao/article/details/127835909