我正在研究采用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)
答案 0 :(得分:1)
您需要更新版本“ jackson-datatype-jsr310”> = 2.8
Alexey Bychkov(joxerTMD @ github)
*贡献#80:添加对String
(2.8.0) / ** *int number = 78; String numberAsString = String.valueOf(number);
的标志 * * @从2.8开始 *
要解决此问题: 在pom.xml中:
JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE