Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2211

Reactive Redis spring boot app - Failed to convert value of type ReactiveRedisTemplate to required type RedisOperations

$
0
0

I tried to migrate the usage of redis to reactive redis in my spring boot app.I have the dependency

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis-reactive</artifactId></dependency>

i`m using version 2.7.18

and i have the following configuration class:

import org.springframework.context.annotation.Bean;import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;import org.springframework.data.redis.core.ReactiveRedisTemplate;import org.springframework.data.redis.serializer.GenericToStringSerializer;import org.springframework.data.redis.serializer.RedisSerializationContext;import org.springframework.data.redis.serializer.StringRedisSerializer;@Configurationpublic class RedisConfig {    @Bean    public ReactiveRedisTemplate<String, Integer> redisTemplate(ReactiveRedisConnectionFactory reactiveRedisConnectionFactory) {        RedisSerializationContext<String, Integer> serializationContext = RedisSerializationContext                .<String, Integer>newSerializationContext(new StringRedisSerializer())                .value(new GenericToStringSerializer<>(Integer.class))                .build();        return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, serializationContext);    }}

when i'm trying to load the app im getting the following error:

2024-10-16 14:24:51 org.springframework.beans.factory.UnsatisfiedDependencyException:Error creating bean with name 'redisReferenceResolver': Unsatisfied dependency expressed through constructor parameter 0:Could not convert argument value of type [org.springframework.data.redis.core.ReactiveRedisTemplate] to required type [org.springframework.data.redis.core.RedisOperations]: Failed to convert value of type 'org.springframework.data.redis.core.ReactiveRedisTemplate' to required type 'org.springframework.data.redis.core.RedisOperations'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.data.redis.core.ReactiveRedisTemplate' to required type 'org.springframework.data.redis.core.RedisOperations': no matching editors or conversion strategy found

Can someone please assist?


Viewing all articles
Browse latest Browse all 2211

Trending Articles