赞
踩
- @RestController
- public class HelloController {
- @Autowired
- private DiscoveryClient client;
-
- @RequestMapping(value = "/hello", method = RequestMethod.GET)
- public String index() {
- java.util.List<ServiceInstance> instances = client.getInstances("hello-service");
- return "Hello World";
- }
-
- @RequestMapping(value = "/offline", method = RequestMethod.GET)
- public void offLine(){
- DiscoveryManager.getInstance().shutdownComponent();
- }
- }

eureka客户端是是一个spring boot应用通过调用以下代码通知注册中心下线。
DiscoveryManager.getInstance().shutdownComponent();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。