Spring boot Jackson2即时序列化

Spring boot Jackson2即时序列化,spring-boot,jackson,Spring Boot,Jackson,我在发送到客户端和从客户端发送到服务器的DTO对象中使用Java8日期/时间API。我使用的是Spring Boot 1.3.2及其默认的Jackson 2。我添加了com.fasterxml.jackson.datatype:jackson-datatype-jsr310模块作为依赖项。尽管如此,Instant实例并没有使用InstantSerializer进行序列化,而是作为一个嵌套的JSON结构编写,包含两个字段,epochSeconds和nano。由于这两个方法作为Instant类中的g

我在发送到客户端和从客户端发送到服务器的DTO对象中使用Java8日期/时间API。我使用的是Spring Boot 1.3.2及其默认的Jackson 2。我添加了
com.fasterxml.jackson.datatype:jackson-datatype-jsr310
模块作为依赖项。尽管如此,
Instant
实例并没有使用
InstantSerializer
进行序列化,而是作为一个嵌套的JSON结构编写,包含两个字段,
epochSeconds
nano
。由于这两个方法作为
Instant
类中的getter是可以发现的,所以我想默认的bean序列化程序会解决这个问题

我想要的是将
Instant
序列化为long,就像
Date
一样。我没有对
ObjectMapper
进行任何额外的定制,所以我希望它能够正常工作