From 9d9d09fd488b851a450207fd724bce74ad0ce6ef Mon Sep 17 00:00:00 2001 From: mikekks Date: Thu, 12 Dec 2024 15:52:27 +0900 Subject: [PATCH] =?UTF-8?q?chore(RedisProperties):=20RedisProperties=20?= =?UTF-8?q?=EB=A5=BC=20=EB=94=B0=EB=A1=9C=20=EC=A0=95=EC=9D=98=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crew/main/external/redis/RedisConfig.java | 9 ++------- .../crew/main/external/redis/RedisProperties.java | 14 ++++++++++++++ .../global/constant/PropertiesConfiguration.java | 11 +++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisProperties.java create mode 100644 main/src/main/java/org/sopt/makers/crew/main/global/constant/PropertiesConfiguration.java diff --git a/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisConfig.java b/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisConfig.java index 200497af..391bf389 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisConfig.java @@ -23,14 +23,9 @@ @EnableCaching public class RedisConfig { - @Value("${spring.data.redis.host}") - private String redisHost; - @Value("${spring.data.redis.port}") - private int redisPort; - @Bean - public RedisConnectionFactory redisConnectionFactory() { - return new LettuceConnectionFactory(redisHost, redisPort); + public RedisConnectionFactory redisConnectionFactory(RedisProperties redisProperties) { + return new LettuceConnectionFactory(redisProperties.getHost(), redisProperties.getPort()); } @Bean diff --git a/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisProperties.java b/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisProperties.java new file mode 100644 index 00000000..b31023e4 --- /dev/null +++ b/main/src/main/java/org/sopt/makers/crew/main/external/redis/RedisProperties.java @@ -0,0 +1,14 @@ +package org.sopt.makers.crew.main.external.redis; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@ConfigurationProperties(prefix = "spring.data.redis") +@RequiredArgsConstructor +public class RedisProperties { + private final String host; + private final int port; +} diff --git a/main/src/main/java/org/sopt/makers/crew/main/global/constant/PropertiesConfiguration.java b/main/src/main/java/org/sopt/makers/crew/main/global/constant/PropertiesConfiguration.java new file mode 100644 index 00000000..a6a12d1a --- /dev/null +++ b/main/src/main/java/org/sopt/makers/crew/main/global/constant/PropertiesConfiguration.java @@ -0,0 +1,11 @@ +package org.sopt.makers.crew.main.global.constant; + +import org.sopt.makers.crew.main.external.redis.RedisProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties(RedisProperties.class) +public class PropertiesConfiguration { + +}