!73 处理session持久化到redis时,LocalDateTime等java8的新时间类序列化失败的问题

Merge pull request !73 from 阿超/dev
This commit is contained in:
省长 2021-10-19 12:35:51 +00:00 committed by Gitee
commit 73d4fe5071
2 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,12 @@
<version>2.11.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.11.2</version>
<optional>true</optional>
</dependency>
</dependencies>

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@ -60,6 +61,7 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
field.setAccessible(true);
ObjectMapper objectMapper = (ObjectMapper) field.get(valueSerializer);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.registerModule(new JavaTimeModule());
this.objectMapper = objectMapper;
} catch (Exception e) {
System.err.println(e.getMessage());