赞
踩
版本说明:
1、配置相关
(1) Eureka服务端
server: port: 8091 # 此处如果配置了context-path,客户端那边的defaultZone就得修改为 http://localhost:8091/eureka/eureka # 服务端defaultZone修改为:http://localhost:8091/eureka servlet: context-path: /eureka eureka: client: # 不需要获取服务端,将其改为false fetch-registry: false # 暂时不需要将自己注册到客户端 register-with-eureka: false # 将eureka服务端指向自己 service-url: defaultZone: http://localhost:8091/eureka
(2)Eureka客户端
server:
port: 8082
servlet:
context-path: /user
spring:
application:
name: userService
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8091
2、报错问题:
DiscoveryClient_USERSERVICE/localhost:userService:8082 - was unable to refresh its cache! This periodic background refresh will be retried in 30 seconds. status = Cannot execute request on any known server stacktrace = com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137)
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134)
at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1045)
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:958)
at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1475)
at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1442)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1623)
3、解决办法:在客户端修改
server:
port: 8082
servlet:
context-path: /user
spring:
application:
name: userService
eureka:
client:
serviceUrl:
# 给这个地址后面加上/eureka, 不论服务端这块地址是什么,都需要在其后面加上/eureka
defaultZone: http://localhost:8091/eureka/eureka
eureka访问地址:http://localhost:8091/eureka
此时也就能检测到实例了。
测试了最新版本:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。