diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java index 0ad05b10b27..ade1968ffe4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java @@ -82,7 +82,7 @@ public class RedisAutoConfiguration { } - @ConfigurationProperties(name = "spring.data.redis") + @ConfigurationProperties(name = "spring.redis") public static class RedisProperties { private String host = "localhost"; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java index c2abc1b9f8e..aaa1b5adfa7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java @@ -17,11 +17,14 @@ package org.springframework.boot.autoconfigure.redis; import org.junit.Test; +import org.springframework.boot.TestUtils; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.StringRedisTemplate; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /** @@ -41,4 +44,15 @@ public class RedisAutoConfigurationTests { assertNotNull(this.context.getBean(StringRedisTemplate.class)); } + @Test + public void testOverrideRedisConfiguration() throws Exception { + this.context = new AnnotationConfigApplicationContext(); + TestUtils.addEnviroment(this.context, "spring.redis.host:foo"); + this.context.register(RedisAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class); + this.context.refresh(); + assertEquals("foo", this.context.getBean(LettuceConnectionFactory.class) + .getHostName()); + } + }