springboot+redis项目实战完整篇
https://www.jianshu.com/p/5596c3a4978d
Springboot+redis
【原创作品】
有关Springboot+redis的配置和使用,完整篇。
此配置,几乎可以无脑的粘贴进项目中使用。
springboot项目的创建可以参考之前:https://www.jianshu.com/p/b9f066a221b0
本篇测试项目github地址:https://github.com/zhengjiaao/springboot-test-redis
1.在springboot项目的pom.xml
文件里加入redis的jar依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<!--======== SpringBoot的配置start ===========-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- hibernate jpa-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--简单快速的访问静态资源(图片、html等)-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--开发阶段使用:springboot热启动(热部署):项目有更改,自动编译:需配置idea true生效-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!--======= SpringBoot的配置end =========-->
<!--springboot中的redis依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>