Trying to use a RedisTemplate bean with GenericJackson2JsonRedisSerializer, but while debugging I noticed Spring Session uses a different RedisTemplate instance.
@Configuration
@EnableRedisHttpSession
public class RedisHttpSessionConfig extends
AbstractHttpSessionApplicationInitializer {
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate<Object, Object> redisTemplate() {
final RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
When running this, Spring Session seems to use the default JdkSerializationRedisSerializer for hashValues, instead of the desired GenericJackson2JsonRedisSerializer.
Removing extends AbstractHttpSessionApplicationInitializer seems to make Spring use the correct RedisTempplate bean, but then Spring Session isn't wired at all.
Using Spring Session 1.3.3, and spring-boot-starter-data -redis 1.5.13.
Any idea what I'm missing?