In spring-data-redis, How do we need configure custom converters that can be auto-wired/injected from Spring boot application or configuration.
I read about @ReadingConverter and @WritingConverter from spring data redis documentation. From this documentation, it is not clear on how to configure them. https://github.com/spring-projects/spring-data-redis/blob/master/src/main/asciidoc/reference/redis-repositories.adoc#redis.repositories.indexes
Does anyone know how to do it?
You have to declare CustomConversions bean named "redisCustomConversions" in your application configuration.
These code may help anyone. Thanks @Mikhail
tested with spring-data-redis-1.8.4.RELEASE
Tested with spring-boot-starter-data-redis:2.0.4.RELEASE.
I was facing a problem where my
OffsetDateTime
properties of my@RedisHash
entity were not being stored when usingCrudRepository
.The problem was that
Jsr310Converters
does not have a converter ofOffsetDateTime
.To solve this, I created a reading converter:
and writing converter:
And registered a
RedisCustomConversions
bean in the configuration: