《server》
eureka:
client:
registerWithEureka: false #false:不作为一个客户端注册到注册中心
fetchRegistry: false #为true时,可以启动,但报异常:Cannot execute request on any known server
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
instance:
hostname: localhost
《client》
#注册中心配置(IP型)
eureka:
instance:
statusPageUrlPath: /actuator/info
healthCheckUrlPath: /actuator/health
home-page-url-path: /
ip-address: 120.xxx.xxx.xxx #决定Eureka服务显示host
hostname: ${eureka.instance.ip-address} #决定服务跳转host,必须指定
prefer-ip-address: false #不设可自己指定,true会自动获取本地ipv4地址
instance-id: ${eureka.instance.ip-address}:${spring.application.name}:${server.port}
client:
serviceUrl:
# defaultZone: http://localhost:6600/eureka/
defaultZone: http://120.xxx.xxx.xxx:6600/eureka/
#注册中心配置(常规型)
eureka:
instance:
statusPageUrlPath: /actuator/info
healthCheckUrlPath: /actuator/health
home-page-url-path: /
client:
serviceUrl:
defaultZone: http://120.xxx.xxx.xxx:6600/eureka/
PS:
1、常规型配置服务必须和网关路由分发在同一机器启动。如果全部为IP型配置则无此限制,在任意机器启动,注册到同一注册中心即可。
2、此处IP必须为可用的公网IP。