我有一个弹簧引导应用程序。我想通过jedisconnectionfactory连接到Redis云服务器,但我做不到。实际上,当我使用本地Redis服务器时,它可以工作。
我编写的Redis配置如下所示。
@Configuration
public class RedisConfig {
@Bean
public JedisConnectionFactory connectionFactory() {
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName( "redis-cli -u redis://redis-19735.c1.us-east1-2.gce.cloud.redislabs.com");
configuration.setPort(19735);
configuration.setUsername("<username_goes_here>");
configuration.setPassword("<password_goes_here>");
return new JedisConnectionFactory(configuration);
}
@Bean
public RedisTemplate<String, Object> redisTemplate(){
RedisTemplate<String,Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory());
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
return template;
}
}此外,您也可以在下面看到我的Redis云数据库。

你能帮我把它联系起来吗?我试图使用jedisconnectionfactory连接Redis云数据库,但我做不到。
发布于 2022-11-10 11:54:44
简单地说,主机名是redis-19735.c1.us-east1-2.gce.cloud.redislabs.com。
https://stackoverflow.com/questions/74381260
复制相似问题