Use RedisSeralizer.java(ClassLoader) factory method

Closes gh-37800
2.7.x
Andy Wilkinson 1 year ago
parent 657656e814
commit 6df5389d76

@ -28,8 +28,8 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.core.ReactiveRedisTemplate; import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.core.ReactiveStringRedisTemplate; import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's reactive Redis * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's reactive Redis
@ -48,14 +48,13 @@ public class RedisReactiveAutoConfiguration {
@ConditionalOnBean(ReactiveRedisConnectionFactory.class) @ConditionalOnBean(ReactiveRedisConnectionFactory.class)
public ReactiveRedisTemplate<Object, Object> reactiveRedisTemplate( public ReactiveRedisTemplate<Object, Object> reactiveRedisTemplate(
ReactiveRedisConnectionFactory reactiveRedisConnectionFactory, ResourceLoader resourceLoader) { ReactiveRedisConnectionFactory reactiveRedisConnectionFactory, ResourceLoader resourceLoader) {
JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer( RedisSerializer<Object> javaSerializer = RedisSerializer.java(resourceLoader.getClassLoader());
resourceLoader.getClassLoader());
RedisSerializationContext<Object, Object> serializationContext = RedisSerializationContext RedisSerializationContext<Object, Object> serializationContext = RedisSerializationContext
.newSerializationContext() .newSerializationContext()
.key(jdkSerializer) .key(javaSerializer)
.value(jdkSerializer) .value(javaSerializer)
.hashKey(jdkSerializer) .hashKey(javaSerializer)
.hashValue(jdkSerializer) .hashValue(javaSerializer)
.build(); .build();
return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, serializationContext); return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, serializationContext);
} }

Loading…
Cancel
Save