【问题标题】:Wrong representation of java.time.Instant fields in Spring Rest APISpring Rest API 中 java.time.Instant 字段的错误表示
【发布时间】:2017-07-12 14:29:08
【问题描述】:

当在 MongoDB 文档中的某些字段上使用新的 Java 8 java.time.Instant 类型,然后使用 @RepositoryRestResource 将其公开时,这些字段将显示如下:

{
  "createdAt": {
    "content": "2017-01-01T00:00:00.000Z"
  }
}

我希望它们看起来像这样:

{
  "createdAt": "2017-01-01T00:00:00.000Z"
}

如何解决此问题?

【问题讨论】:

标签: spring spring-data-mongodb spring-data-rest


【解决方案1】:

如果您使用的是 Spring Boot,您可能会遇到一个问题,该问题出现在版本 1.4.0 中,并在版本 1.4.1(或可能是 1.4.2,取决于您的应用程序中存在的一些注释或不是)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 2018-02-03
    • 1970-01-01
    • 2014-03-27
    • 2020-04-12
    相关资源
    最近更新 更多