package at.gv.egiz.moazs.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; @Configuration public class RedisConfig { public RedisConfig() { } @Value("${spring.redis.host}") private String host; @Value("${spring.redis.port}") private int port; @Bean JedisConnectionFactory jedisConnectionFactory() { RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(); config.setHostName(host); config.setPort(port); return new JedisConnectionFactory(config); } @Bean public StringRedisSerializer stringRedisSerializer() { return new StringRedisSerializer(); } @Bean public RedisTemplate redisTemplate() { final RedisTemplate template = new RedisTemplate(); template.setConnectionFactory(jedisConnectionFactory()); template.setDefaultSerializer(stringRedisSerializer()); return template; } }