Spring Cloud入门之二、服务发现

eureka-service 服务注册/发现中心

官方参考文档

复制必备

  1. pom.xml
  2. application.yml
  3. EurekaServiceApplication.java中@EnableEurekaServer

airport-service 机场服务(通过Spring Eureka注册服务)

复制必备

  1. pom.xml
  2. application.yml
  3. AirportServiceApplication.java中@EnableEurekaClient

查看结果

前置条件

  • eureka-service启动后至少1分钟
  • airport-service启动后观察eureka-service接收到3次心跳

查看方法

aircraft-service 飞机服务(使用服务发现来查找服务)

复制必备

  1. pom.xml
  2. application.yml
  3. AircraftServiceApplication.java中getRestTemplate()

查看结果

http://localhost:8100/v1/aircraft/HangZhou/

发布了182 篇原创文章 · 获赞 42 · 访问量 59万+

猜你喜欢

转载自blog.csdn.net/wyyl1/article/details/81288368
今日推荐