4
I am in a project with Spring 4 configuring the Redis and a construction like this has emerged:
@Configuration
@ComponentScan({"com.empresa.sistema.web.util"})
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(jedisConnectionFactory());
template.setKeySerializer(stringRedisSerializer());
template.setHashKeySerializer(stringRedisSerializer());
return template;
}
}
It works perfectly, but now I wanted to do something like this:
@Bean
public RedisTemplate<String, T> redisTemplate() {
RedisTemplate<String, T> template = new RedisTemplate<String, T>();
template.setConnectionFactory(jedisConnectionFactory());
template.setKeySerializer(stringRedisSerializer());
template.setHashKeySerializer(stringRedisSerializer());
return template;
}
How can I do?