Spring 中 java.time.Instant 字段的错误表示 Rest API
Wrong representation of java.time.Instant fields in Spring Rest API
当在 MongoDB 文档中的某些字段上使用新的 Java 8 java.time.Instant 类型,然后使用 @RepositoryRestResource 公开它时,这些字段将显示如下:
{
"createdAt": {
"content": "2017-01-01T00:00:00.000Z"
}
}
我希望它们看起来像这样:
{
"createdAt": "2017-01-01T00:00:00.000Z"
}
我该如何解决这个问题?
如果您使用的是 Spring 启动,您可能会遇到发行版 1.4.0, and was fixed in release 1.4.1 (or possibly 1.4.2 中出现的问题,具体取决于您的应用程序中是否存在某些注释。
当在 MongoDB 文档中的某些字段上使用新的 Java 8 java.time.Instant 类型,然后使用 @RepositoryRestResource 公开它时,这些字段将显示如下:
{
"createdAt": {
"content": "2017-01-01T00:00:00.000Z"
}
}
我希望它们看起来像这样:
{
"createdAt": "2017-01-01T00:00:00.000Z"
}
我该如何解决这个问题?
如果您使用的是 Spring 启动,您可能会遇到发行版 1.4.0, and was fixed in release 1.4.1 (or possibly 1.4.2 中出现的问题,具体取决于您的应用程序中是否存在某些注释。