package com.amazon.aws; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; @Configuration @ConfigurationProperties("spring.redis") public class Config { private String host; private Integer port; public String getHost() { return host; } public void setHost(String host) { this.host = host; } public Integer getPort() { return port; } public void setPort(Integer port) { this.port = port; } @Bean public LettuceConnectionFactory redisConnectionFactory() { if (this.host != null && this.port != null) { return new LettuceConnectionFactory(new RedisStandaloneConfiguration(this.host, this.port)); } else { return new LettuceConnectionFactory(new RedisStandaloneConfiguration()); } } }