diff --git a/src/main/java/swm_nm/morandi/domain/testDuring/config/RedisConfig.java b/src/main/java/swm_nm/morandi/domain/testDuring/config/RedisConfig.java index 6c416228..5d134434 100644 --- a/src/main/java/swm_nm/morandi/domain/testDuring/config/RedisConfig.java +++ b/src/main/java/swm_nm/morandi/domain/testDuring/config/RedisConfig.java @@ -1,24 +1,25 @@ package swm_nm.morandi.domain.testDuring.config; +import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; + @Configuration +@RequiredArgsConstructor public class RedisConfig { - @Bean - public LettuceConnectionFactory redisConnectionFactory() { - return new LettuceConnectionFactory(); - } + private final RedisConnectionFactory redisConnectionFactory; @Bean public RedisTemplate redisTemplate() { RedisTemplate template = new RedisTemplate<>(); - template.setConnectionFactory(redisConnectionFactory()); + template.setConnectionFactory(redisConnectionFactory); template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(new GenericJackson2JsonRedisSerializer()); return template;