一、背景描述
项目技术:Spring boot (v2.0.0.RELEASE) + Mybatis plus (3.1.1) + Spring Session (2.0.2.RELEASE)
在引入Spring session
Parameter 1 of method sessionRepositoryFilterRegistration in org.springframework.boot.autoconfigure.session.SessionRepositoryFilterConfiguration 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'
二、原因分析
根据错误日志
Bean method ‘redisConnectionFactory’ not loaded because @ConditionalOnClass did not find required class ‘io.lettuce.core.RedisClient’ 得出未加载Bean方法“redisConnectionFactory”,因为@ConditionalOnClass未找到所需的类。
三、解决方案
3.1 添加spring-boot-starter-data-redis的依赖
~~~~
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>2.0.0.RELEASE</version> </dependency>
3.2 添加jedis依赖
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>3.0.1</version> </dependency>
完结!