Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use RedisRepositories and KeyValueRepositories?

I'm trying to use @EnableRedisRepositories and @EnableMapRepositories in a project and I'm getting the following error message:

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisConverter': Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext] to required type [org.springframework.data.redis.core.mapping.RedisMappingContext]: Failed to convert value of type 'org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext' to required type 'org.springframework.data.redis.core.mapping.RedisMappingContext'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext' to required type 'org.springframework.data.redis.core.mapping.RedisMappingContext': no matching editors or conversion strategy found

So is it possible to use both in the same project?

like image 690
vrish88 Avatar asked Jun 24 '18 14:06

vrish88


People also ask

What is ReactiveRedisTemplate?

public class ReactiveRedisTemplate<K,V> extends Object implements ReactiveRedisOperations<K,V> Central abstraction for reactive Redis data access implementing ReactiveRedisOperations . Performs automatic serialization/deserialization between the given objects and the underlying binary data in the Redis store.

What is the use of RedisTemplate?

Once established, RedisTemplate becomes the main abstraction of Redis' operations that we can command. It also takes care of serialization and deserialization of objects to byte arrays. By default, RedisTemplate uses the JdkSerializationRedisSerializer to serialize and deserialize objects.

What is StringRedisTemplate?

public class StringRedisTemplate extends RedisTemplate<String,String> String-focused extension of RedisTemplate. Since most operations against Redis are String based, this class provides a dedicated class that minimizes configuration of its more generic template especially in terms of serializers.


1 Answers

There is known issue https://jira.spring.io/browse/DATAREDIS-846.

As a workaround you may disable repository auto configuration:

spring.data.redis.repositories.enabled=false

And add

@EnableRedisRepositories(basePackages="org.my.redis.repositories")

instead.

like image 80
Taras Danylchuk Avatar answered Oct 20 '22 20:10

Taras Danylchuk