springboot2.x引入spring-boot-starter-data-redis依赖,启动报错

阿飞千秋万载 发布于 10/10 11:53
阅读 286
收藏 0

springboot2.x引入spring-boot-starter-data-redis依赖,启动报错,redis框架用的jedis就没问题,2.x默认用的是lettuce却出现了以下错误,为什么会这样,这个问题折腾了两三天了,快点来个大神拯救我吧
pom:

报错:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'application': Unsatisfied dependency expressed through field 'stringredistemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stringRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'stringRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Unsatisfied dependency expressed through method 'redisConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lettuceClientResources' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.lettuce.core.resource.DefaultClientResources]: Factory method 'lettuceClientResources' threw exception; nested exception is java.lang.NoClassDefFoundError: io/netty/util/internal/logging/InternalLoggerFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
 

加载中
1
KevinBlandy
KevinBlandy

添加一个依赖

<dependency>
	<groupId>io.lettuce</groupId>
	<artifactId>lettuce-core</artifactId>
</dependency>

 

阿飞千秋万载
回复 @阿飞千秋万载 : 手动下载lettuce包成功运行了
阿飞千秋万载
你好,我加了,然而还是报同样错误
0
c
cquzxs

问题点: java.lang.NoClassDefFoundError: io/netty/util/internal/logging/InternalLoggerFactory 

加上这个包试一下

<!-- https://mvnrepository.com/artifact/org.elasticsearch.plugin/transport-netty4-client -->
<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>transport-netty4-client</artifactId>
    <version>7.1.0</version>
</dependency>
 

 


 

阿飞千秋万载
回复 @zb40251488 : 手动下载lettuce包成功运行了
zb40251488
zb40251488
是缺少netty-all的包, <dependency>     <groupId>io.netty</groupId>     <artifactId>netty-all</artifactId> <version>4.0.24.Final</version> </dependency>
0
cafelication
cafelication

版本问题 用这个替换掉之前的 springboot-start-data-redis

<!--Spring整合redis包 -->
<dependency>
   <groupId>org.springframework.data</groupId>
   <artifactId>spring-data-redis</artifactId>
   <version>2.1.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
   <groupId>redis.clients</groupId>
   <artifactId>jedis</artifactId>
   <version>2.9.1</version>
</dependency>
返回顶部
顶部