解决问题:java.net.UnknownHostException

版权声明:Soulmate_Min专属 https://blog.csdn.net/Soulmate_Min/article/details/82764556

错误信息:

2018-09-18 21:11:40.808 ERROR [userapp,,,] 5128 --- [           main] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error

com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: server2
	at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
	at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
	at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.6.2.jar:1.6.2]
	at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
	at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
	at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
	at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[jersey-client-1.19.1.jar:1.19.1]

服务注册不到Eureka上, 因为本地调用远程Eureka服务器时,需要配置本地的Host文件。

1.首先找到host的配置文件:C:\Windows\System32\drivers\etc

WIN7,WIN8,WIN10 默认的位置都在这个路径下。

用记事本打开配置文件。将服务器Eureka注册中心的外网访问地址  和 名字配置好, 保存即可解决问题。

猜你喜欢

转载自blog.csdn.net/Soulmate_Min/article/details/82764556
今日推荐