Commit c4b01870 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #16604 from dlmu-lq

* pr/16604:
  Polish "Auto-configure ReactiveStringRedisTemplate if necessary"
  Auto-configure ReactiveStringRedisTemplate if necessary
parents 81543873 922ceed6
...@@ -28,6 +28,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -28,6 +28,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader; 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.serializer.JdkSerializationRedisSerializer; import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.RedisSerializationContext;
...@@ -60,4 +61,12 @@ public class RedisReactiveAutoConfiguration { ...@@ -60,4 +61,12 @@ public class RedisReactiveAutoConfiguration {
serializationContext); serializationContext);
} }
@Bean
@ConditionalOnMissingBean(name = "reactiveStringRedisTemplate")
@ConditionalOnBean(ReactiveRedisConnectionFactory.class)
public ReactiveStringRedisTemplate reactiveStringRedisTemplate(
ReactiveRedisConnectionFactory reactiveRedisConnectionFactory) {
return new ReactiveStringRedisTemplate(reactiveRedisConnectionFactory);
}
} }
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -41,7 +41,8 @@ public class RedisReactiveAutoConfigurationTests { ...@@ -41,7 +41,8 @@ public class RedisReactiveAutoConfigurationTests {
public void testDefaultRedisConfiguration() { public void testDefaultRedisConfiguration() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
Map<String, ?> beans = context.getBeansOfType(ReactiveRedisTemplate.class); Map<String, ?> beans = context.getBeansOfType(ReactiveRedisTemplate.class);
assertThat(beans).containsOnlyKeys("reactiveRedisTemplate"); assertThat(beans).containsOnlyKeys("reactiveRedisTemplate",
"reactiveStringRedisTemplate");
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment