错误信息如下:
error org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
起初认为是redisIP在配置中的错误,排查配置发现没有问题,postman测试接口发现redis连接正常,百度查之。
发现以下博文:
https://blog.csdn.net/qq_36743013/article/details/110221803
随即恍然大悟,spring boot admin 默认检测微服务中的所有指标信息,包括redis,如果配置文件中没有设置,则会根据默认的localhost配置去尝试连接redis,因此导致指标异常,如果当前微服务不需要连接redis,可以在配置文件中关闭这项指标的检测。如下:
management:
health:
redis:
enabled: false
重启服务后,可见指标被移除,服务监测页面显示正常。
自己使用整理收集,如有侵权 请联系删除!