Skip to content

Commit b2e5bd2

Browse files
authored
Merge pull request #106 from Capstone-OpenStep/feature/#100-badge-api
Fix: Redis 연결시 누락된 username 필드 RedisConfig에 추가
2 parents 073d9fd + fd28e32 commit b2e5bd2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/chungang/capstone/openstep/global/config/RedisConfig.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class RedisConfig {
2222
@Value("${spring.data.redis.port}")
2323
private int port;
2424

25+
@Value("${spring.data.redis.username:}")
26+
private String username;
27+
2528
@Value("${spring.data.redis.password}")
2629
private String password;
2730

@@ -32,7 +35,11 @@ public class RedisConfig {
3235
public LettuceConnectionFactory redisConnectionFactory() {
3336
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(host, port);
3437

35-
if (!password.isBlank()) {
38+
if (username != null && !username.isBlank()) {
39+
config.setUsername(username);
40+
}
41+
42+
if (password != null && !password.isBlank()) {
3643
config.setPassword(RedisPassword.of(password));
3744
}
3845

@@ -42,7 +49,8 @@ public LettuceConnectionFactory redisConnectionFactory() {
4249
builder.useSsl();
4350
}
4451

45-
return new LettuceConnectionFactory(config, builder.build());
52+
LettuceClientConfiguration clientConfig = builder.build();
53+
return new LettuceConnectionFactory(config, clientConfig);
4654
}
4755

4856

0 commit comments

Comments
 (0)