From 77b364e710c0700f453a65ce5878683b94a34d14 Mon Sep 17 00:00:00 2001 From: suhyeon7497 Date: Fri, 11 Oct 2024 20:35:14 +0900 Subject: [PATCH] =?UTF-8?q?[chore]=20redis.yaml=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit redis.yaml 파일로 config 관리 관련 이슈 : #44 --- .../team7/inplace/security/config/RedisConfig.java | 10 +++++++++- src/main/resources/application-redis.yaml | 4 ++++ src/main/resources/application.yaml | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/application-redis.yaml diff --git a/src/main/java/team7/inplace/security/config/RedisConfig.java b/src/main/java/team7/inplace/security/config/RedisConfig.java index 425cbcae..980689e4 100644 --- a/src/main/java/team7/inplace/security/config/RedisConfig.java +++ b/src/main/java/team7/inplace/security/config/RedisConfig.java @@ -1,5 +1,6 @@ package team7.inplace.security.config; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; @@ -10,9 +11,16 @@ @Configuration public class RedisConfig { + @Value("${redis.db.url}") + private String redisDBUrl; + + @Value("${redis.db.port}") + private Integer redisDBPort; + @Bean LettuceConnectionFactory redisConnectionFactory() { - return new LettuceConnectionFactory(new RedisStandaloneConfiguration("localhost", 6379)); + return new LettuceConnectionFactory( + new RedisStandaloneConfiguration(redisDBUrl, redisDBPort)); } @Bean diff --git a/src/main/resources/application-redis.yaml b/src/main/resources/application-redis.yaml new file mode 100644 index 00000000..c6585435 --- /dev/null +++ b/src/main/resources/application-redis.yaml @@ -0,0 +1,4 @@ +redis: + db: + url: ${REDIS_DATABASE_URL} + port: ${REDIS_DATABASE_PORT} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index e5b3642d..767b4ebd 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -5,4 +5,5 @@ spring: - classpath:application-youtube.yaml - classpath:application-kakao.yaml - classpath:application-db.yaml + - classpath:application-redis.yaml - optional:file:.env[.properties]