7

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?

MohamadKh75
  • 2,582
  • 5
  • 28
  • 54
vrish88
  • 20,047
  • 8
  • 38
  • 56

1 Answers1

3

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.

  • You also need to ensure `@EnableRedisRepositories` gets processed before `@EnableMapRepositories` meaning; if they are on same class `@EnableRedisRepositories` needs to appear on top of `@EnableMapRepositories`. – Soner Koksal Aug 19 '20 at 12:53