I am using Jackson2JsonRedisSerializer.
@Bean public RedisOperations<String , Aircraft> redisOperations(RedisConnectionFactory factory){ Jackson2JsonRedisSerializer<Aircraft> serializer = new Jackson2JsonRedisSerializer<Aircraft>(Aircraft.class); RedisTemplate<String, Aircraft> template = new RedisTemplate<>(); template.setConnectionFactory(factory); template.setDefaultSerializer(serializer); template.setKeySerializer(new StringRedisSerializer()); return template; } My aircraft has field of type Instant.
@JsonProperty("last_seen_time") private Instant lastSeenTime; While deserializing it gives me an error:
Java 8 date/time type `java.time.Instant` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: com.example.chapter6.sburredis.Aircraft["last_seen_time"]) I have already added the maven dependency in my pom.xml
<dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>2.14.1</version> </dependency> The json file is as follows:
{ "aircraft": [ { "id": 108, "callsign": "AMF4263", "squawk": "4136", "reg": "N49UC", "flightno": "", "route": "LAN-DFW", "type": "B190", "category": "A1", "altitude": 20000, "heading": 235, "speed": 248, "lat": 38.865905, "lon": -90.429382, "barometer": 0, "vert_rate": 0, "selected_altitude": 0, "polar_distance": 12.99378, "polar_bearing": 345.393951, "is_adsb": true, "is_on_ground": false, "last_seen_time": 1672576769, "pos_update_time": 1672576769, "bds40_seen_time": null } ] }