直接使用Jackson 解析 Java 8 之後提供的 LocalDate 會發生,Java 8 date/time type not supported by default.
找到的解決方法.
Java 8 LocalDate With Jackson In Spring Boot
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.3</version>
</dependency>
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
沒有留言:
張貼留言