微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

redis 报错 NoSuchFieldError: DEFAULT. redis netty

redis 报错 NoSuchFieldError: DEFAULT

具体报错如下:

Exception in thread "main" java.lang.NoSuchFieldError: DEFAULT
	at io.lettuce.core.AbstractRedisClient.connectionBuilder(AbstractRedisClient.java:222)
	at io.lettuce.core.RedisClient.connectStatefulAsync(RedisClient.java:313)
	at io.lettuce.core.RedisClient.connectStandaloneAsync(RedisClient.java:278)
	at io.lettuce.core.RedisClient.connect(RedisClient.java:211)
	at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115)
	at java.util.Optional.orElseGet(Optional.java:267)
	at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1459)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1247)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1230)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:979)
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:359)
	at org.springframework.data.redis.core.RedisConnectionUtils.fetchConnection(RedisConnectionUtils.java:193)
	at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:144)
	at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:105)
	at org.springframework.data.redis.core.Redistemplate.execute(Redistemplate.java:209)
	at org.springframework.data.redis.core.Redistemplate.execute(Redistemplate.java:189)
	at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)
	at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53)
	at com.dingxuan.sky.dxp.udp.client.SkyDxpUdpClientApplication.main(SkyDxpUdpClientApplication.java:21)

依赖版本

			  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
  					<version>2.4.5</version>
        </dependency>
<!--redis 里面依赖了 lettuce的版本 ,如下图-->
				<dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
 	 					<version>5.0.0.Alpha1</version>
        </dependency>

		


 

image-20210929164630370

redis里面依赖了lettuce的版本,lettuce本身集成了netty 4.1 的版本,与项目本身集成的5.0 版本冲突。

解决办法:

  1. 将本身集成的netty的版本与lettuce的版本改成一致的。

  2. 去掉lettuce 改集成 jedis

    image-20210929165153240

依赖jedis版本需要查看 spring-boot-starter-data-redis 对应的jedis版本,2.4.5 认对应 jedis 的 3.3.0版本

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐