java.nio.channels.UnresolvedAddressException

  • Post author:
  • Post category:java




报错信息如下

java.nio.channels.UnresolvedAddressException



Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to…



排查原因

经过排查是 RocketMQ和redis的包 netty有冲突

RocketMQ 版本 4.4.0

redis 版本 spring-data-redis 2.2.13.RELEASE

RocketMQ 需要引入了netty-all-4.0.42.Final.jar

redis引入

在这里插入图片描述



解决办法

RocketMQ去除 netty-all这个包

<dependency>
			<groupId>org.apache.rocketmq</groupId>
			<artifactId>rocketmq-client</artifactId>
			<version>4.4.0</version>
			 <exclusions>
				<exclusion>
					<groupId>io.netty</groupId>
               		<artifactId>netty-all</artifactId>
				</exclusion>
			</exclusions> 
		</dependency>



分析

RocketMQ 的netty包在

rocketmq-client-》commons-lang3-》netty-all(版本 4.0.42.Final)

Redis的netty的包在

spring-boot-starter-data-redis-》spring-data-redis-》lettuce-core-》netty相关 (这里有多个 ;并且 版本在4.1.45.Final 这个在上面的截图也看到了)

再来看看netty-all里面的一些信息

在这里插入图片描述

在这里插入图片描述

这些信息和redis里面引入的包是一样的,但是版本不一样,因此版本不同因此了冲突



版权声明:本文为Myueye原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。