1. 程式人生 > >Eureka常用配置以及常見問題總結

Eureka常用配置以及常見問題總結

首先 祭出eureka的官方文件

  • 新增@EnableEurekaClient 註解
  • 匯入依賴
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
  • yml配置
eureka:
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: http://localhost:8761
/eureka instance: prefer-ip-address: true instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} lease-renewal-interval-in-seconds: 5

emergency! eureka may be incorrectly claiming instances are up when they’re not. renewals are lesser
這個警告是由於我們心跳小於5下 就會報出提示(不影響使用)