2021-09-29

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)

依赖版本

              
            org.springframework.boot
            spring-boot-starter-data-redis
                    2.4.5
        

                
            io.netty
            netty-all
                        5.0.0.Alpha1
        

        


 
maven xml

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

解决办法:

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

  2. 去掉lettuce 改集成 jedis


    maven xml

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

你可能感兴趣的:(2021-09-29)