马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
步调01 引入Redis依赖包
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-data-redis
</artifactId>
</dependency>
步调02 修改设置文件
在application.properties设置文件增长有关Redis的设置:
步调03 验证测试
@SpringBootTest
public class TestRedisTemplate{
@Autowired
private RedisTemplate redisTemplate;
@Test
public void testString(){
//调用set()方法创建缓存
redisTemplate.opsForVaule().set("hello:redis","hello spring boot");
System.out.println("hello,redis:"+redisTemplate.opsForValue().get("hello:redis"));
}
}
|