LocalDateTime is not converted to String but to Json object

大憨熊 提交于 2019-12-05 21:11:30

Ok, sorry for the delay. I checked it and if you look into the Neo4j database in target/cmmn.db it shows that the date is correctly serialized as string.

bin/neo4j-shell -path target/cmmn.db/

neo4j-sh (?)$ match (n) return *
> ;
+--------------------------------------------------------------------------------------+
| n                                                                                    |
+--------------------------------------------------------------------------------------+
| Node[0]{name:"Senat"}                                                                |
| Node[1]{name:"Cato",description:"Ceterum Censeo",creationDate:"2011-12-03T10:15:30"} |
+--------------------------------------------------------------------------------------+
2 rows

I think the issue is rather with the json-converters of spring-data-rest, which might not be configured for LocalDateTime.

You have to add this as dependency:

    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>2.4.5</version>
    </dependency>

Then the leaves are rendered as:

  "name" : "Cato",
  "description" : "Ceterum Censeo",
  "creationDate" : "2011-12-03T10:15:30",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/leaf/7"
    }

See: https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring#customizing-the-jackson-objectmapper

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