springboot整合缓存
1、整合ehcache(之后再写)
2、整合redis
1、导包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2、配置yml文件
redis:
host: 121.40.x.x
port: 6379
password: 12345
3、测试
@Autowired
StringRedisTemplate redisTemplate;
@Test
void testRedis(){
ValueOperations<String, String> ops = redisTemplate.opsForValue();
ops.set("hello", "word");
String hello = ops.get("hello");
System.out.println(hello);
}
4、结果
- 计划任务
- 完成任务