Eureka常用配置介绍:
Eureka Server:
spring:
application:
name: lfq-eureka
server:
port: 8761
eureka:
client:
###代表不将自己注册到注册中心服务 集群设置为true
register-with-eureka: false
##代表是否从其他注册中心服务获取服务 集群设置为true
fetch-registry: false
##设置交互地址,查询以及注册都需要这个地址,多个地址用","隔开
service-url:
defaultZone: http://localhost:8761/eureka/
server:
##关闭自我保护模式
enable-self-preservation: false
##清理失效服务时间 默认6000ms ******生产环境下不建议使用
eviction-interval-timer-in-ms: 5000
Service:
spring:
application:
name: lfq-provide-8081
server:
port: 8081
eureka:
client:
service-url:
##defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
defaultZone: http://localhost:8761/eureka/
instance:
##自定义instanceID
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
##设置instanceID可点击
prefer-ip-address: true
##表示服务提供者发送心跳给Eureka的时间频率 默认30s
lease-renewal-interval-in-seconds: 10
##表示第一次收到这个instanceID之后,在这个时间段内如果该instanceID还没有注册,则清除这个服务 默认90s
lease-expiration-duration-in-seconds: 30
更多配置请看源码:org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean