🔴 The Error You're Seeing
Confirm this matches your console output. If it does, you're in the right place.
2026-02-20 12:15:10.220 ERROR 8842 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the object a type supported by the serializer?] with root cause
org.springframework.data.redis.serializer.SerializationException: Cannot deserialize⚡ Quick Fix Works 80% of the time
Make the cached object implement Serializable, or configure a JSON serializer.
public class User implements Serializable {
private static final long serialVersionUID = 1L;
// fields...
}🧠 Why this Happens
Tap to expand the deep technical explanation
Spring Data Redis uses JDK serialization by default. It tried to convert the bytes stored in Redis back into a Java object, but failed. This happens if the Java class doesn't implement `Serializable`, lacks a `serialVersionUID`, or if you recently changed the class structure after caching the data.
The HITEC City Parking Spot Analogy:
It's like trying to open a locked safe with the wrong key. The safe (Redis) holds the data, but the key (Java serialization) doesn't match the lock, so it refuses to open.
🔁 How to Reproduce Confirm this is your error
Create a class that does NOT implement Serializable. Cache an instance in Redis using @Cacheable. Retrieve it. It will crash.
🛠️ Solutions (5 Ways to Fix)
Make the cached class implement Serializable
👉 Use this if you are using the default JDK serializer.
Java serialization requires the class to implement `Serializable`. Add `implements Serializable` and a `serialVersionUID`.
import java.io.Serializable;
public class User implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
}Configure GenericJackson2JsonRedisSerializer
👉 Use this as the enterprise best practice.
Instead of brittle Java serialization, tell Spring Boot to serialize objects as JSON before storing them in Redis.
@Bean
public RedisCacheConfiguration cacheConfiguration() {
return RedisCacheConfiguration.defaultCacheConfig()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()));
}Clear the Redis cache
👉 Use this if you recently changed the class structure (added/removed fields).
Old bytes in Redis no longer match the new Java class. Flushing Redis forces a clean slate.
# Connect to Redis CLI
redis-cli
# Flush all data
FLUSHALLAdd serialVersionUID
👉 Use this if you forgot to add it and the class evolved.
If you don't define a `serialVersionUID`, Java generates one based on the class structure. Changing the class changes the ID, breaking deserialization of old data.
private static final long serialVersionUID = 1L;Ensure default constructor exists
👉 Use this if using Jackson JSON serialization.
Jackson needs a default (no-args) constructor to instantiate the object before populating fields.
public class User {
public User() {} // Required for Jackson
// ...
}📋 Version Notes
Uses JdkSerializationRedisSerializer by default.
Uses JdkSerializationRedisSerializer by default, but auto-configuration heavily favors JSON serializers.
🛡️ How to Prevent This Next Time
Never use default JDK serialization for Redis in production. Always configure a JSON serializer (`GenericJackson2JsonRedisSerializer`).