Maven依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
Yaml配置
server:
port: 8090
#注册到Eureka服务中心
eureka:
client:
service-url:
# 注册到集群,就把多个Eurekaserver地址使用逗号连接起来即可;注册到单实例(非集群模式),那就写一个就ok
defaultZone: http://CloudEurekaServerA:8761/eureka,http://CloudEurekaServerB:8762/eureka
instance:
prefer-ip-address: true #服务实例中显示ip,而不是显示主机名(兼容老的eureka版本)
# 实例名称: 192.168.1.103:cloud-service-resume:8080,我们可以自定义它
instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}:@project.version@
spring:
application:
name: cloud-service-autodeliver
#针对的被调用方微服务名称,不加就是全局生效
#lagou-service-resume:
# ribbon:
# NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RoundRobinRule #负载策略调整
# springboot中暴露健康检查等断点接口
management:
endpoints:
web:
exposure:
include: "*"
# 暴露健康接口的细节
endpoint:
health:
show-details: always
Main函数启动类注解配置
![](https://i-blog.csdnimg.cn/blog_migrate/9b5fe86ca85ecebe7d7d72c4fdafcbd2.png)
项目启动后页面展示
![](https://i-blog.csdnimg.cn/blog_migrate/2a723cbb4da7da0d818143b4951b0813.png)
服务请求与服务提供者元数据获取
![](https://i-blog.csdnimg.cn/blog_migrate/1cb7e620796adc06f3b52e5d00195fc5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cdcdcc670c5b22a4b2da23e36016b0d9.png)