Spring Cloud快速开始
本文档演示如何将Spring Cloud服务接入到Apache ShenYu网关。您可以直接在工程下找到本文档的示例代码 。
环境准备
请参考运维部署的内容,选择一种方式启动shenyu-admin。比如,通过 本地部署 启动Apache ShenYu后台管理系统。
启动网关,如果是通过源码的方式,直接运行shenyu-bootstrap中的ShenyuBootstrapApplication。
启动顺序
- 启动
shenyu-admin - 启动
shenyu-bootstrap - 启动注册中心,例如
shenyu-examples下的eureka项目 - 配置
shenyu-examples-springcloud注册发现
shenyu:
discovery:
enable: true
type: eureka
serverList: ${eureka.client.serviceUrl.defaultZone}
registerPath: ${spring.application.name}
props:
nacosNameSpace: ShenyuRegisterCenter
运行 shenyu-examples-springcloud
示例项目中我们使用 eureka 作为 Spring Cloud的注册中心。你可以使用本地的eureka,也可以使用示例中提供的应用。
下载 shenyu-examples-eureka 、shenyu-examples-springcloud .
启动eureka