【发布时间】:2020-04-30 21:45:39
【问题描述】:
spring webclient 无法从 eureka 服务器的服务实例名称中检索实际主机并出现以下异常:
java.net.UnknownHostException: USER-DATA-SERVICE
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_161]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ Request to GET http://USER-DATA-SERVICE/users/01 [DefaultWebClient]
Spring boot 版本:2.2.3.BUILD-SNAPSHOT & Spring Cloud 版本:Hoxton.BUILD-SNAPSHOT
【问题讨论】:
-
请提供更多信息,例如您的依赖项和配置以及
http://<eurekaserver>/eureka/apps的输出 -
Consumer Client application.yml -------------------------------- spring : application : name :用户信息服务服务器:端口:8801 eureka:实例:主机名:本地主机客户端:fetch-registry:true register-with-eureka:true service-url:defaultZone:localhost:8700/eureka
-
发现客户端 application.yml ------------------------------------ spring :应用程序:名称:user-eureka-discovery-service 服务器:端口:8700 eureka:实例:主机名:localhost 客户端:fetch-registry:false register-with-eureka:false service-url:defaultZone:http://${ spring.application.name}:${server.port}/eureka/
-
相同的编码工作正常 RestTemplate 但如果我们更改 webClient 然后得到 unkownhost 异常
标签: spring-boot spring-cloud spring-webflux netflix-eureka spring-webclient