这可能是由于您的代码中的错误.您正在使用新的未配置的mapper实例,这是修复:
ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String now = mapper.writeValueAsString(new SomeClass(LocalDateTime.now())); System.out.println(now);