com.fasterxml.jackson.datatype:jackson-datatype-jsr310
看详细报错信息:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
//添加格式
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "Asia/Shanghai")
private LocalDateTime createTime;
不在报错
测试20s失效时间:
Map<Object, Object> tokenDataMap = MapUtil.newHashMap();
LocalDateTime now = LocalDateTime.now();
LocalDateTime dateTime = now.plusSeconds(20);
DateTimeFormatter formatterOfTarget = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String startTime = now.format(formatterOfTarget);
String endTime = dateTime.format(formatterOfTarget);
tokenDataMap.put(UserCenterConsts.TOKEN_CREATE_TIME,startTime);//创建时间
tokenDataMap.put(UserCenterConsts.TOKEN_EXPIRE_TIME, endTime);//失效时间
redisService.hmset(key, tokenDataMap, UserCenterConsts.TOKEN_CACHE_EXPIRE, TimeUnit.SECONDS);
|