我正在研究采用JSON对象并将其持久保存在关系数据库中:
实体:

import java.time.ZonedDateTime;

...

private ZonedDateTime zonedDateTime ;
public ZonedDateTime getZonedDateTime () {
        return zonedDateTime ;
    }
public void setZonedDateTime (ZonedDateTime zonedDateTime ) {
        this.zonedDateTime = zonedDateTime ;
    }


我对pom.xml添加了依赖项:

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>


但是当我致电服务部门时:

ERROR [org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler] (ThreadPoolTaskScheduler-7) Unexpected error occurred in
 scheduled task.: java.lang.NoSuchFieldError: ADJUST_DATES_TO_CONTEXT_TIME_ZONE
    at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.createContextual(InstantDeserializer.java:231)
    at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:685)
    at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:446)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:948)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:446)
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
    at com.fasterxml.jackson.databind.deser.DeserializerCache.hasValueDeserializerFor(DeserializerCache.java:191)
    at com.fasterxml.jackson.databind.DeserializationContext.hasValueDeserializerFor(DeserializationContext.java:422)
    at com.fasterxml.jackson.databind.ObjectMapper.canDeserialize(ObjectMapper.java:2664)
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:162)
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:149)
    at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:765)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:650)
    at org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:128)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:287)


这里同样的问题http://qaru.site/questions/13631592/nosuchfielderror-adjustdatestocontexttimezone-when-trying-to-parse-json

最佳答案

您需要更新版本“ jackson-datatype-jsr310”> = 2.8


  Alexey Bychkov(joxerTMD @ github)
  *贡献80:添加对
  JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE(2.8.0)
  / **
       * JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE的标志
       *
       * @从2.8开始
       *


解决方法:
 在pom.xml中:

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
    <version>2.8.11</version>
</dependency>

关于java - 计划的任务发生意外错误。java.lang.NoSuchFieldError:ADJUST_DATES_TO_CONTEXT_TIME_ZONE,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56376887/

10-09 21:49