监控与管理
状态页和健康指标
- 在需要检查的注册项目的pom.xml 文件中添加springboot中的actuator依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
使用EurekaClient
一旦您拥有@EnableDiscoveryClient(或@EnableEurekaClient)的应用程序,您就可以使用它来从Eureka服务器发现服务实例。一种方法是使用本机com.netflix.discovery.EurekaClient(而不是Spring云DiscoveryClient),例如
@Autowired
private EurekaClient discoveryClient;
public String serviceUrl() {
InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false);
return instance.getHomePageUrl();
}