这是我的工作方式:
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); jedisConnectionFactory.setHostName(redisHost); jedisConnectionFactory.setPort(Integer.parseInt(redisPort)); jedisConnectionFactory.afterPropertiesSet(); RedisTemplate<String, Object> redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(jedisConnectionFactory); redisTemplate.setDefaultSerializer(new StringRedisSerializer()); redisTemplate.afterPropertiesSet(); SimpleRegistry registry = new SimpleRegistry(); registry.put("redisTemplate", redisTemplate);
属性文件:
redisUri = spring-redis://notused?redisTemplate=#redisTemplateredisHost = [stuff].xavwv8.ng.0001.euw1.cache.amazonaws.comredisPort = 6379
因此,显然,当您使用连接工厂时,以后无法将主机设置为在URI中使用。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)