After configuring spring-session-data-redis
in a demo spring-boot project, bootRun
task fails with the following message:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration required a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' that could not be found.
- Bean method 'redisConnectionFactory' not loaded because @ConditionalOnClass did not find required classes 'org.apache.commons.pool2.impl.GenericObjectPool', 'redis.clients.jedis.Jedis'
- Bean method 'redisConnectionFactory' not loaded because @ConditionalOnClass did not find required class 'io.lettuce.core.RedisClient'
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration.
What I've done (a.k.a. steps to reproduce):
1. Used Spring Initializr to create a [Gradle with Java and Spring Boot 2.1.0 M1 + Web dependency] project.
2. Followed the Spring Session - Spring Boot instructions to configure Spring Session. More specifically:
- added compile 'org.springframework.session:spring-session-data-redis'
to build.gradle's dependencies block
- configured the store type by adding spring.session.store-type=redis
to application.properties
file
- configured the connection
properties (in application.properties
file): spring.redis.host
,
spring.redis.password
and spring.redis.port
with relevant values
3. Executed ./gradlew bootRun
from the root of the project and received the above error
Questions:
1. As far as I'm understand from the error message, RedisConnectionFactory
failed to load because it can't find neither Jedis nor Lettuce drivers. Shouldn't spring-session-data-redis
bring one of those drivers by default?
2. How to resolve this issue in case I want to use the Jedis driver?
3. How to resolve this issue in case I want to use the Lettuce driver?
spring-boot-starter-data-redis
as well, this pulls in a driver by default.spring-boot-starter-data-redis
, nor explicit driver dependency. Also, it seems that this is a behavior change - I'm able to runbootRun
using spring-boot's1.5.16.BUILD-SNAPSHOT
version flawlessly without explicit driver dependency.spring-boot-starter-data-redis
dependency, or explicitly by addingio.lettuce:lettuce-core
dependency?