RestController 返回对象抛错 HttpMessageNotWritableException

使用 @RestController,理应会自动转成 json 对象,但是却抛错。

HttpMessageNotWritableException: No converter found for return value of type

可能的原因:

  • 返回的对象没有 getter 方法
  • 没有导包
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.4</version>
</dependency>

我是导包的问题。

参考