Skip to content

Instantly share code, notes, and snippets.

@samuelstein
Created March 24, 2026 14:18
Show Gist options
  • Select an option

  • Save samuelstein/7b4bade4796c0862b6d5d8719cf212c4 to your computer and use it in GitHub Desktop.

Select an option

Save samuelstein/7b4bade4796c0862b6d5d8719cf212c4 to your computer and use it in GitHub Desktop.
Spring Boot 4 & Jackson 3 & Redis cache

Spring Boot 4 & Jackson 3 & Redis cache

Requirement

  • You use JSON serialization and deserialization for Redis values
  • You use Java records

Issue

JSON deserialization for cached Redis values always throws exception like:

Caused by: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class ...

Solution

Use org.springframework.data.redis.serializer.RedisSerializer.json() as value serializer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment