java- feign:无法反序列化java.time.Instant

时间:2018-07-29 22:56:33

标签: java deserialization feign java.time.instant

在我的模型中,有一些类型为Instant的字段。假装似乎无法反序列化它。运行测试时出现以下错误消息:

feign.FeignException: Can not construct instance of java.time.Instant: no String-argument constructor/factory method to deserialize from String value ('2018-07-29T21:28:23.013Z')
 at [Source: java.io.BufferedReader@3f06abd; line: 1, column: 805] (through reference chain: com.test.api.profile.model.testProfile["finishDate"]) reading GET http://localhost:8080/testProfile/<uuid>

我已经在我的application.java文件中这样做了

// Customize global JSON serialization settings
        bootstrap.getObjectMapper()
            .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

在我的测试用例的@Before中:

objectMapper.registerModule(new JavaTimeModule());

请帮助

0 个答案:

没有答案