springboot整合redis
测试一下
1.导入依赖
<!--操作redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2.配置链接
#配置redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
3.测试
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
@SpringBootTest
class Redis02SpringbootApplicationTests {
@Autowired
private RedisTemplate redisTemplate;
@Test
void contextLoads() {
redisTemplate.opsForValue ().set ("mykey","xingfuhao");
System.out.println (redisTemplate.opsForValue ().get ("mykey"));
}}
最后
以上就是友好爆米花最近收集整理的关于springboot整合redis的全部内容,更多相关springboot整合redis内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复