@Configuration public class RedisConfiguraion { @Bean public JedisConnectionFactory redisConnectionFactory() { RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); configuration.setHostName("ip地址"); configuration.setPort(6379); //configuration.setPassword(RedisPassword.of("123456")); return new JedisConnectionFactory(configuration); } @Bean public RedisTemplate redisTemplate(JedisConnectionFactory factory){ RedisTemplate redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(factory); return redisTemplate; } }
基本的配置是这样的。