仔细看看SpringBoot官方提供的参考手册会发现:
关于Redis部分,springboot支持jedis和lettuce。但是默认配置的是lettuce。
如果要使用jedis方式处理redis,需要特殊配置,官方参考手册也提示需要特殊配置。
配置方式主要是修改pom.xml文件:
https://docs.spring.io/spring-boot/docs/2.0.0.BUILD-SNAPSHOT/reference/htmlsingle/#howto-use-jedis-instead-of-lettuce
86.6 Use Jedis instead of Lettuce
The Spring Boot starter (spring-boot-starter-data-redis
) uses Lettuce by default. You need to exclude that dependency and include the Jedis one instead. Spring Boot manages these dependencies to help make this process as easy as possible.
Example in 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>
Example in Gradle:
configurations { compile.exclude module: "lettuce" } dependencies { compile("redis.clients:jedis") // ... }