Spring MVC Eureka 服务器调用API时出现异常

kxeu7u2r  于 2023-02-05  发布在  Spring
关注(0)|答案(2)|浏览(158)

我已经使用spring Boot 创建了微服务,在从本地服务器调用URL http://localhost:8765/CURRENCY-EXCHANGE/currency-exchange/from/USD/to/INR时,微服务会出现异常

例外详细信息:

java.net.UnknownHostException: failed to resolve 'DESKTOP-HG47DMC' after 2 queries 
at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s):
|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP GET "/CURRENCY-EXCHANGE/currency-exchange/from/USD/to/INR" [ExceptionHandlingWebHandler] Stack trace:
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1013) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:966) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:414) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:625) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:63) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:458) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) [netty-common-4.1.63.Final.jar:4.1.63.Final]
    at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:201) ~[netty-resolver-dns-4.1.63.Final.jar:4.1.63.Final]

这是我申请表。属性

spring.application.name = api-gateway
server.port = 8765
eureka.client.serviceUrl.defaultZone =http://localhost:8761/eureka
spring.cloud.gateway.discovery.locator.enabled= true
6uxekuva

6uxekuva1#

将此代码片段添加到微服务的application.properties文件中。

eureka.instance.hostname=localhost
aelbi1ox

aelbi1ox2#

将此代码片段添加到application.properties所有微服务(命名服务器、API网关和货币兑换)的www.example.com文件中。

Eureka 了。示例。主机名=本地主机*

如果您收到404响应,请等待30 - 60秒。

相关问题