I am hosting my application on AWS. I have configured my property files as follow below
spring.redis.host = {AWS host endpoint} spring.redis.port = 6379
Connection between my application works. However, spring attempts to always conneect to local host first before connecting to the aws host endpoint, therefore throwing the error. The error is shown below.
2017-05-30 10:37:58.203 [main] ERROR redis.clients.jedis.HostAndPort:
cant resolve localhost address
How do i resolve this please thank you
EDIT Below shows my Redis config class
@Configuration
@EnableCaching
public class RedisCacheConfig {
final Logger logger = LoggerFactory.getLogger(RedisCacheConfig.class);
JedisConnectionFactory connectionFactory;
@Autowired
public RedisCacheConfig(JedisConnectionFactory connectionFactory) {
this.connectionFactory = connectionFactory;
}
@Bean
@Autowired
public CacheManager getCacheManager(CacheExpiration expiration) {
RedisCacheManager manager = new RedisCacheManager(getRedisTemplate());
manager.setExpires(expiration.getMapper());
//expiration.getMapper();
return manager;
}
@Bean
public RedisTemplate getRedisTemplate() {
RedisTemplate template = new RedisTemplate();
template.setConnectionFactory(connectionFactory);
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
return template;
}
}