jackson ObjectMapper不会将JSON的StringMap到ZonedDateTime

vaj7vani  于 6个月前  发布在  其他
关注(0)|答案(1)|浏览(78)

我正在用MockMvc编写集成测试,并希望将我的响应作为对象接收,以便对其进行Assert。
线

AuthenticationResponse authenticationResponse = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), AuthenticationResponse.class);

字符串
抛出错误:Unable to make field private final java.time.ZoneOffset java.time.ZonedDateTime.offset accessible: module java.base does not "opens java.time" to unnamed module
通常使用我的应用程序没有错误。在测试中只有一个错误。
搜索Stackoverflow没有帮助,因为没有类似的问题。

xwbd5t1u

xwbd5t1u1#

您需要使用以下标志运行测试:

java ... --add-opens java.base/java.time=ALL-UNNAMED

字符串
标签:https://github.com/spring-projects/spring-data-mongodb/issues/3893

相关问题