|
11 | 11 | import org.springframework.data.redis.core.RedisTemplate; |
12 | 12 | import org.springframework.data.redis.core.StringRedisTemplate; |
13 | 13 | import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; |
14 | | -import org.springframework.data.redis.serializer.GenericToStringSerializer; |
15 | 14 | import org.springframework.data.redis.serializer.RedisSerializer; |
16 | 15 | import org.springframework.data.redis.serializer.StringRedisSerializer; |
17 | 16 |
|
@@ -40,20 +39,20 @@ public RedisTemplate<Object, Object> redisObjectTemplate() { |
40 | 39 | redisTemplate.setValueSerializer(new StringRedisSerializer()); |
41 | 40 | return redisTemplate; |
42 | 41 | } |
| 42 | + |
43 | 43 | @Bean |
44 | 44 | public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) { |
45 | 45 | RedisTemplate<String, Object> template = new RedisTemplate<>(); |
46 | 46 | template.setConnectionFactory(connectionFactory); |
47 | 47 |
|
48 | | - // 🔹 JSON 직렬화 설정 |
49 | 48 | ObjectMapper objectMapper = new ObjectMapper(); |
50 | | - objectMapper.registerModule(new JavaTimeModule()); // LocalDateTime 지원 추가 |
51 | | - objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // ISO 8601 포맷 유지 |
| 49 | + objectMapper.registerModule(new JavaTimeModule()); |
| 50 | + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); |
52 | 51 |
|
53 | 52 | RedisSerializer<Object> serializer = new GenericJackson2JsonRedisSerializer(objectMapper); |
54 | 53 |
|
55 | | - template.setKeySerializer(new StringRedisSerializer()); // 키 직렬화 |
56 | | - template.setValueSerializer(serializer); // 값 직렬화 |
| 54 | + template.setKeySerializer(new StringRedisSerializer()); |
| 55 | + template.setValueSerializer(serializer); |
57 | 56 | template.setHashKeySerializer(new StringRedisSerializer()); |
58 | 57 | template.setHashValueSerializer(serializer); |
59 | 58 |
|
|
0 commit comments