Skip to content

Commit

Permalink
chore(RedisProperties): RedisProperties 를 따로 정의하여 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed Dec 12, 2024
1 parent 76538c4 commit 9d9d09f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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 {

}

0 comments on commit 9d9d09f

Please sign in to comment.