首页>代码>Spring Cloud搭建Eureka Server服务注册发现Eureka Client简单实例>/eureka-service-discovery/bookstore-service/src/main/java/com/memorynotfound/cloud/DiscoveryController.java
package com.memorynotfound.cloud;

import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.shared.Applications;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
public class DiscoveryController {

    @Autowired
    private EurekaClient eurekaClient;

    @GetMapping("/applications")
    public Applications getApplications() {
        return eurekaClient.getApplications();
    }

    @GetMapping("/regions")
    public Set<String> getRegions() {
        return eurekaClient.getAllKnownRegions();
    }

    @GetMapping("/instances/{app-name}")
    public List<InstanceInfo> getInstancesByVipAddress(@PathVariable("app-name") String appName) {
        return eurekaClient.getInstancesByVipAddress(appName, false);
    }
}
最近下载更多
644106  LV8 2023年6月8日
mmmmmmppp  LV10 2023年5月16日
zsf0061  LV8 2023年3月13日
iceboard  LV2 2023年2月26日
sunlzh888888  LV28 2021年6月22日
StevenB  LV1 2021年5月13日
planckstars  LV5 2021年5月7日
snrzyf  LV7 2021年4月19日
打怪升级自学成菜  LV6 2021年2月25日
灯泡两个  LV2 2020年12月12日
最近浏览更多
3305787467  LV12 2023年6月24日
644106  LV8 2023年6月8日
mmmmmmppp  LV10 2023年5月16日
King_wsk  LV18 2023年3月24日
啦啦啦7719  LV15 2023年3月24日
zsf0061  LV8 2023年3月13日
iceboard  LV2 2023年2月26日
  LV6 2022年12月6日
bibibi234  LV1 2022年12月4日
Sunsi12345  LV8 2022年11月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友