在tornadofx中使用localdatetime和其余的springboot

我开发了一个带有springboot rest服务的tornadofx应用程序作为后端
所有在kotlin语言

问题是tornadofxSeNd LocalDateTime作为Int这会导致这个错误在springboot服务器

2018-01-31 18:33:31.296 WARN 11473 --- [nio-8080-exec-2] .wsmsDefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected token (VALUE_NUMBER_INT), expected VALUE_STRING: Expected array or string.; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (VALUE_NUMBER_INT), expected VALUE_STRING: Expected array or string. at [Source: (PushbackInputStream); line: 1, column: 16] (through reference chain: andalous.torndadoserver.financial.dailymove.newDailyMove["date"]) 

我添加到springboot但不能解决

  com.fasterxml.jackson.datatype jackson-datatype-jsr310 2.9.1  

并在application.properties中使用它

 spring.jackson.serialization.write_dates_as_timestamps=false 

你可以自由地以任何你喜欢的方式序列化JSON数据。 而不是做json.add("key", someLocalDateTimeValue)你可以做json.add("key", someLocalDataTimeValueConvertedToWhateverFormatYouWant) 。 你甚至可以添加一个扩展function,使它很好的工作。

也就是说,如何在内置的JsonBuilder中存储LocalDateTime的配置选项应该是非常容易的。 公关将是最欢迎:)

这是与tornadofx完美的工作方式

 override fun toJSON(json: JsonBuilder) { with(json){ add("date",date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) } } override fun updateModel(json: JsonObject) { with(json){ date= LocalDateTime.parse(string("date"),DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) } }