80. Running Spring Cloud Services in Development

Launcher CLI 可用于从命令 line 中运行 Eureka,Config Server 等 common common 服务。列出可用的服务spring cloud --list,并启动一组默认服务spring cloud。要选择要部署的服务,只需在命令 line,e.g 上列出它们。

$ spring cloud eureka configserver h2 kafka stubrunner zipkin

支持的可部署的摘要:

服务名称地址描述
eurekaEureka Serverhttp://localhost:8761Eureka 服务器用于服务注册和发现。默认情况下,所有其他服务都显示在其目录中。
configserver配置服务器http://localhost:8888Spring Cloud Config Server running in“native”profile 并从本地目录./launcher 提供 configuration
H2H2 数据库http://localhost:9095( console),jdbc:h2:tcp://localhost:9096/ {。 11}关系数据库服务。连接时使用{data}(e.g. ./target/test)的文件路径。请记住,您可以添加;MODE=MYSQL;MODE=POSTGRESQL以连接与其他服务器类型的兼容性。
kafkaKafka Brokerhttp://localhost:9091( actuator endpoints),localhost:9092
hystrixdashboardHystrix 仪表板http://localhost:7979声明 Hystrix 断路器的任何 Spring Cloud 应用程序在/hystrix.stream上发布 metrics。在仪表板中键入该地址以显示所有 metrics,
数据流数据流服务器http://localhost:9393Spring Cloud 数据流服务器,UI 位于/admin-ui。将 Dataflow shell 连接到根路径的目标。
zipkinZipkin 服务器http://localhost:9411Zipkin Server 带有用于可视化跟踪的 UI。 在 memory 中存储 span 数据并通过 HTTP POST 的 JSON 数据接受它们。
stubrunnerStub Runner Boothttp://localhost:8750下载 WireMock 存根,启动 WireMock 并使用存储的存根提供已启动的服务器。传递stubrunner.ids以传递存根坐标,然后转到http://localhost:8750/stubs

可以使用具有相同 name 的本地 YAML 文件(在当前工作目录或名为“config”或~/.spring-cloud的子目录中)配置这些应用程序中的每一个。 E.g。在configserver.yml中你可能想要做这样的事情来为后端找到一个本地 git repository:

configserver.yml.

spring:
  profiles:
    active: git
  cloud:
    config:
      server:
        git:
          uri: file://${user.home}/dev/demo/config-repo

E.g。在 Stub Runner 应用程序中,您可以通过以下方式从本地.m2获取存根。

stubrunner.yml.

stubrunner:
  workOffline: true
  ids:
    - com.example:beer-api-producer:+:9876

80.1 添加其他 Applications

可以将其他 applications 添加到./config/cloud.yml(不是./config.yml因为它将替换默认值),e.g. 同

config/cloud.yml.

spring:
  cloud:
    launcher:
      deployables:
        source:
          coordinates: maven://com.example:source:0.0.1-SNAPSHOT
          port: 7000
        sink:
          coordinates: maven://com.example:sink:0.0.1-SNAPSHOT
          port: 7001

当您列出应用时:

$ spring cloud --list
source sink configserver dataflow eureka h2 hystrixdashboard kafka stubrunner zipkin

(注意列表开头的其他应用程序)。