Реактивное приложение весенней загрузки Redis — не удалось преобразовать значение типа ReactiveRedisTemplate в требуемыйJAVA

Программисты JAVA общаются здесь
Anonymous
Реактивное приложение весенней загрузки Redis — не удалось преобразовать значение типа ReactiveRedisTemplate в требуемый

Сообщение Anonymous »

Я пытался перенести использование Redis на реактивный Redis в моем приложении Spring Boot.
У меня есть зависимость

Код: Выделить всё

org.springframework.boot
spring-boot-starter-data-redis-reactive

Я использую версию 2.7.18
и у меня есть следующий класс конфигурации:

Код: Выделить всё

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;

@Configuration
public class RedisConfig {

@Bean
public ReactiveRedisTemplate redisTemplate(ReactiveRedisConnectionFactory reactiveRedisConnectionFactory) {
RedisSerializationContext serializationContext = RedisSerializationContext
.newSerializationContext(new StringRedisSerializer())
.value(new GenericToStringSerializer(Integer.class))
.build();

return new ReactiveRedisTemplate(reactiveRedisConnectionFactory, serializationContext);
}
}
когда я пытаюсь загрузить приложение, я получаю следующую ошибку:

Код: Выделить всё

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
Может кто-нибудь помочь?

Подробнее здесь: https://stackoverflow.com/questions/790 ... iverediste

Вернуться в «JAVA»