87.6 使用Lettuce来代替Jedis

Spring Boot starter(spring-boot-starter-data-redis)默认使用Lettuce。你需要排除那个依赖,并把Jedis的依赖加入进来。Spring Boot管理这些依赖,使这些步骤尽可能容易。

Maven的例子:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>

Gradle的例子:

configurations {
compile.exclude module: "lettuce"
}
dependencies {
compile("redis.clients:jedis")
// ...
}