我们正在使用Java中ObjectMapper的杰克逊序列化。
对于LocalDateTime
,在本地运行的代码输出以下日志:
"date":"2019-11-28T18:56:00.328Z"
在jenkins上运行的相同代码会产生其他结果:
"date":{"offset":{"totalSeconds":0,"id":"Z","rules":{"fixedOffset":true,"transitions":[],"transitionRules":[]}},"zone":{"totalSeconds":0,"id":"Z","rules":{"fixedOffset":true,"transitions":[],"transitionRules":[]}},"dayOfWeek":"THURSDAY","dayOfYear":332,"hour":18,"minute":46,"second":55,"nano":948000000,"year":2019,"month":"NOVEMBER","dayOfMonth":28,"monthValue":11,"chronology":{"calendarType":"iso8601","id":"ISO"}}
在应用程序启动中,我们执行以下操作:
Json.mapper.findAndRegisterModules();
Json.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
Json.mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
Json.mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
和pom.xml中的依赖项是
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.4</version>
</dependency>
编辑:
詹金斯机器具有不同的语言环境/时区