SpringBoot.2.4.0整合redis
作者:互联网
引入依赖
<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>
再次测试
然后就可以使用redis的相关api了
标签:4.0,spring,redisConnectionFactory,redis,lettuce,jedis,SpringBoot.2,boot 来源: https://www.cnblogs.com/kaka-qiqi/p/15171288.html