163. Spring Boot Redis version problem [Learn Spring Boot from scratch]

 

【Video & Communication Platform】

à SpringBoot Video 

http://study.163.com/course/introduction.htm?courseId=1004329008&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à  SpringCloud Video

http://study.163.com/course/introduction.htm?courseId=1004638001&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à Spring Boot source code 

https://gitee.com/happyangellxq520/spring-boot

à Spring Boot communication platform 

http://412887952-qq-com.iteye.com/blog/2321532

 

Origin of need :

       In the blog " 35. Spring Boot integrates Redis to implement caching mechanism [Learn Spring Boot from scratch ] "

A netizen commented :

With the following, there is no RedisTemplate

 

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-redis</artifactId>
        </dependency>
 

Finally, use the following
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
 

 

       Is this the blogger's distraction? This blog reveals whether it is a blog written by the blogger when he sleeps .

 

 

The error produces :

Using version 1.5 to introduce redis will not succeed, and the folder that is automatically downloaded to the local maven library is also an " unknown " folder. It is OK to use 1.3 and 1.4 ... The following configuration method:

<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-redis </artifactId>
</dependency>

 

       这样的配置在1.5+版本就无法使用redis。在1.4版本的更新日志中有这么一段说明:

Renamed starters
The following starters have been renamed, the old ones will be removed in Spring Boot 1.5

spring-boot-starter-ws → spring-boot-starter-web-services
spring-boot-starter-redis → spring-boot-starter-data-redis

 

上面大体的意思就是:以下的starters已经被重新命令,老的版本在1.5会被移除掉。

 

使用方式

当使用的是1.4(包括1.4版本)之前的版本使用如下配置:

<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-redis </artifactId>
</dependency>

 

       当使用的是1.5+的版本使用如下配置:

<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-data-redis </artifactId>
</dependency>

 

 

       这里要特别注意下1.4版本是一个过渡版本,所以当你使用的spring boot1.4.x版本的话,那么使用上面的哪一种方式都是可以的,建议使用官方新的配置方式。

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326641617&siteId=291194637