自定义部署

本文介绍如何基于 Apache ShenYu 搭建属于你自己的网关。

在阅读本文档前,你需要先阅读部署先决条件文档来完成部署shenyu前的环境准备工作.

启动Apache ShenYu Admin

  • docker 用户参考 docker部署 Apache ShenYu Admin

  • liunx/windows 用户参考二进制包部署 Apache ShenYu Admin

搭建自己的网关(推荐)

  • 首先新建一个空的 springboot 项目,可以参考 shenyu-bootstrap, 也可以在 spring 官网 创建。

  • 引入如下jar包:

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-webflux</artifactId>
  5. <version>2.2.2.RELEASE</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-actuator</artifactId>
  10. <version>2.2.2.RELEASE</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>org.apache.shenyu</groupId>
  14. <artifactId>shenyu-spring-boot-starter-gateway</artifactId>
  15. <version>${current.version}</version>
  16. </dependency>
  17. <dependency>
  18. <groupId>org.apache.shenyu</groupId>
  19. <artifactId>shenyu-spring-boot-starter-sync-data-websocket</artifactId>
  20. <version>${current.version}</version>
  21. </dependency>
  22. </dependencies>

其中, ${project.version} 请使用当前最新版本。

  • 在你的 application.yaml 文件中加上如下配置:
  1. spring:
  2. main:
  3. allow-bean-definition-overriding: true
  4. management:
  5. health:
  6. defaults:
  7. enabled: false
  8. shenyu:
  9. sync:
  10. websocket:
  11. urls: ws://localhost:9095/websocket //设置成你的 shenyu-admin 地址