建立在之前的基础上,这次我进行了redis实验。
1.首先我要去https://github.com/microsoftarchive/redis/releases,下载安装。
![](https://img.haomeiwen.com/i7568033/3a45fe92157f3975.png)
2.安装比较简单哈,就省略了。安装完了,我就测试下是否安装成功。cd到安装目录下执行redis-server.exe redis.windows.conf
![](https://img.haomeiwen.com/i7568033/9200588a30f6db24.png)
长成这样就ok了。
3.由于之前下载springboot包的时候,已经选择了redis,这里就不用再去添加redis的依赖了。没有的话就需要再pom.xml中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
4.写了一段测试代码先看看
@RequestMapping("/redisTest")
public static String redisTest() {
Jedis jedis = new Jedis("localhost");
jedis.set("name", "wangyu");
return jedis.get("name");
}
5.成功,页面显示wangyu
![](https://img.haomeiwen.com/i7568033/631f6dca5228197c.png)
网友评论