Skip to content

Commit

Permalink
fix: Redisson 패스워드 설정 구문 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chhs2131 committed Aug 23, 2024
1 parent 517b9a6 commit affdbdf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ public class RedisConfig {
private String redisHost;

@Value("${spring.data.redis.port}")
private String redisPort;
private int redisPort;

@Value("${spring.data.redis.password}")
private String redisPassword;

@Bean
public RedissonClient redissonClient() {
RedissonClient redisson = null;
Config config = new Config();
config.useSingleServer().setAddress("redis://" + redisHost + ":" + redisPort);
redisson = Redisson.create(config);
return redisson;
config.useSingleServer()
.setAddress("redis://" + redisHost + ":" + redisPort)
.setPassword(redisPassword);
return Redisson.create(config);
}

@Bean
public RedisConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setHostName(redisHost);
redisStandaloneConfiguration.setPort(Integer.parseInt(redisPort));
redisStandaloneConfiguration.setPort(redisPort);
redisStandaloneConfiguration.setPassword(redisPassword);

return new LettuceConnectionFactory(redisStandaloneConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
public class EmbeddedRedisConfig {

@Value("${spring.data.redis.port}")
private String redisPort;
private int redisPort;

@Value("${spring.data.redis.password}")
private String redisPassword;

private RedisServer redisServer;

@PostConstruct
public void redisServer() throws IOException {
redisServer = new RedisServer(Integer.parseInt(redisPort));
redisServer = RedisServer.newRedisServer()
.port(redisPort)
.setting("requirepass " + redisPassword)
.build();

redisServer.start();
}

Expand Down

0 comments on commit affdbdf

Please sign in to comment.