如果像下面的代码那样创建自定义ObjectMapper类,它将覆盖默认的objectMapper,而您根本不需要xml配置:
@Servicepublic class CustomObjectMapper extends ObjectMapper { public CustomObjectMapper() { this.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); this.registerModule(new JodaModule()); }}我已经将此简单服务添加到简单的spring boot应用程序中,并以预期的格式获得了时间。



