天天看點

Zipkin start 和 redis start 不相容

Spring boot 版本: <code>2.2.1.RELEASE</code>

Spring cloud 版本 : <code>Hoxton.RC1</code>

項目中同時使用了

spring-cloud-starter-zipkin

spring-boot-starter-data-redis

在編碼中有多個Service同時注入了RedisTemplate&lt;String, String&gt; redisTemplate導緻在Tomcat啟動時報錯,導緻無法運作。

錯誤如下

[ main] o.a.c.loader.WebappClassLoaderBase : The web application

[ROOT] appears to have started a thread named [lettuce-eventExecutorLoop-1-1] but has failed to stop it. This is very likely to create a memory leak.

Stack trace of thread:

sun.misc.Unsafe.park(Native Method)`

Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host=‘172.31.214.234’, port=6380], RedisURI [host=‘172.31.214.234’, port=6381], RedisURI [host=‘172.31.214.235’, port=6380], RedisURI [host=‘172.31.214.235’, port=6381], RedisURI [host=‘172.31.214.236’, port=6380], RedisURI [host=‘172.31.214.236’, port=6381]

最終原因是Redis 用戶端lettuce無法連接配接上Redis導緻該報錯。

解決

移除spring-boot-starter-data-redis中對lettuce的引用,加入jedis的依賴 。springcloud架構www.1b23.com

當我移除spring-cloud-starter-zipkin 之後再次啟動項目發現啟動成功,spring-boot-starter-data-redis預設使用lettuce作為Redis的用戶端,是以推斷為spring-cloud-starter-zipkin 可能和lettuce有相容性問題。

是以嘗試把lettuce換為jedis,問題解決。

繼續閱讀