How to make spring use StringRedisSerializer to store session into redis by java code instead of xml config file
<p>My spring stores session into redis, but the key is like "\xac\xed\x00\x05t\x00(spring:session". Now I want to remove the weird prefix and I know the solution is using StringRedisSerializer in RedisTemplate, but my config code below does not work:</p>

<pre><code>@EnableRedisHttpSession()
@Configuration
public class SpringSessionConfig {

    @Autowired
    JedisConnectionFactory jedisConnectionFactory;

    StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(StandardCharsets.UTF_8);

    @Bean
    public StringRedisTemplate redisTemplate() {
        StringRedisTemplate redisTemplate = new StringRedisTemplate();
        redisTemplate.setConnectionFactory(this.jedisConnectionFactory);
        redisTemplate.setDefaultSerializer(this.stringRedisSerializer);
        redisTemplate.setHashKeySerializer(this.stringRedisSerializer);
        redisTemplate.setKeySerializer(this.stringRedisSerializer);
        return redisTemplate;
    }
}
</code></pre>

<p>There are answers that using xml config file to do the same thing, but I prefer using pure java code, anyone can help with the above code? Thx.</p>