How do I avoid content fields in Joda objects?

淺唱寂寞╮ 提交于 2019-12-04 04:21:20

问题


I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this

lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" }

instead of

lastAggregationDate: "2016-07-12T17:58:43.643Z"

I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here.

I've duplicated this behavior in a slightly modified Spring sample project but using Java's native date types rather than Joda's. I've added a date of birth property to the Person object and modified the shouldRetrieveEntity test to look for $.dateOfBirth.content. I've confirmed the serializer is being used and it seems like the LocalDate object is being treated as a resource rather than as a simple property.


回答1:


This is fixed in Spring Data Hopper-SR4: https://jira.spring.io/browse/DATAMONGO-1498




回答2:


The issue results from Spring Boot not setting up MongoMappingContext correctly. A ticket has been created for Spring Boot and the fix is anticipated for the 1.4.1 release (credit for this answer goes to Oyku Gencay and Oliver Gierke). For more detail, see the ticket or the pull request.



来源:https://stackoverflow.com/questions/39172792/how-do-i-avoid-content-fields-in-joda-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!