eureka获取指定应用的每个实例地址

获取instance信息

 @Autowired
 DiscoveryClient discoveryClient;
    
 public List serviceUrl(String service) {
        List instances = discoveryClient.getInstances(service);
        return instances;
    }

返回实例

[
  {
    "instanceInfo": {
      "instanceId": "XXX-h0257:XXX:3000",
      "app": "XXX",
      "appGroupName": null,
      "ipAddr": "11.1.98.15",
      "sid": "na",
      "homePageUrl": "http://11.1.98.15:3000/",
      "statusPageUrl": "http://11.1.98.15:3000/info",
      "healthCheckUrl": "http://11.1.98.15:3000/health",
      "secureHealthCheckUrl": null,
      "vipAddress": "XXX",
      "secureVipAddress": "XXX",
      "countryId": 1,
      "dataCenterInfo": {
        "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
        "name": "MyOwn"
      },
      "hostName": "11.1.98.15",
      "status": "UP",
      "leaseInfo": {
        "renewalIntervalInSecs": 10,
        "durationInSecs": 90,
        "registrationTimestamp": 1480504169270,
        "lastRenewalTimestamp": 1480504388555,
        "evictionTimestamp": 0,
        "serviceUpTimestamp": 1480504169271
      },
      "isCoordinatingDiscoveryServer": false,
      "metadata": {},
      "lastUpdatedTimestamp": 1480504169271,
      "lastDirtyTimestamp": 1480504168214,
      "actionType": "ADDED",
      "asgName": null,
      "overriddenStatus": "UNKNOWN"
    },
    "serviceId": "XXX",
    "metadata": {},
    "uri": "http://11.1.98.15:3000",
    "secure": false,
    "host": "11.1.98.15",
    "port": 3000
  },
  {
    "instanceInfo": {
      "instanceId": "XXX-s4lwl:XXX:3000",
      "app": "XXX",
      "appGroupName": null,
      "ipAddr": "11.1.16.11",
      "sid": "na",
      "homePageUrl": "http://11.1.16.11:3000/",
      "statusPageUrl": "http://11.1.16.11:3000/info",
      "healthCheckUrl": "http://11.1.16.11:3000/health",
      "secureHealthCheckUrl": null,
      "vipAddress": "XXX",
      "secureVipAddress": "XXX",
      "countryId": 1,
      "dataCenterInfo": {
        "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
        "name": "MyOwn"
      },
      "hostName": "11.1.16.11",
      "status": "UP",
      "leaseInfo": {
        "renewalIntervalInSecs": 10,
        "durationInSecs": 90,
        "registrationTimestamp": 1480504289728,
        "lastRenewalTimestamp": 1480504570040,
        "evictionTimestamp": 0,
        "serviceUpTimestamp": 1480504289728
      },
      "isCoordinatingDiscoveryServer": false,
      "metadata": {},
      "lastUpdatedTimestamp": 1480504289728,
      "lastDirtyTimestamp": 1480504289735,
      "actionType": "ADDED",
      "asgName": null,
      "overriddenStatus": "UNKNOWN"
    },
    "serviceId": "XXX",
    "metadata": {},
    "uri": "http://11.1.16.11:3000",
    "secure": false,
    "host": "11.1.16.11",
    "port": 3000
  }
]

你可能感兴趣的:(java,c#)