I have Spring Redis working using spring-data-redis
with all default configuration likes localhost
default port
and so on.
Now
Here is an elegant solution to solve your issue :
@Configuration
@PropertySource(name="application", value="classpath:application.properties")
public class SpringSessionRedisConfiguration {
@Resource
ConfigurableEnvironment environment;
@Bean
public PropertiesPropertySource propertySource() {
return (PropertiesPropertySource) environment.getPropertySources().get("application");
}
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory(sentinelConfiguration(), poolConfiguration());
}
@Bean
public RedisSentinelConfiguration sentinelConfiguration() {
return new RedisSentinelConfiguration(propertySource());
}
@Bean
public JedisPoolConfig poolConfiguration() {
JedisPoolConfiguration config = new JedisPoolConfiguration();
// add your customized configuration if needed
return config;
}
@Bean
RedisTemplate
so, to resume :
Tested in my workspace, Regards