引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
添加配置 (默认client-type是lettuce)
spring:
redis:
host: xxx
port: 6379
client-type: lettuce
测试
@Autowired
RedisConnectionFactory redisConnectionFactory;
@Test
public void test6(){
System.out.println(redisConnectionFactory);
}
切换jedis的话,可以这样做
引入jedis依赖
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>