Http服务接入
本文档旨在帮助 http 服务接入到 Apache ShenYu 网关。Apache ShenYu 网关使用 divide 插件来处理 http 请求。
接入前,请正确启动 shenyu-admin,并开启divide插件,在网关端和Http服务端引入相关依赖。可以参考前面的 Http快速开始。
应用客户端接入的相关配置请参考:客户端接入配置。
数据同步的相关配置请参考:数据同步配置。
在网关中引入 divide 插件
-
在网关的
pom.xml文件中增加如下依赖:<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-divide</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-httpclient</artifactId>
<version>${project.version}</version>
</dependency>
Http请求接入网关(springMvc 体系用户)
-
SpringBoot用户可以参考:shenyu-examples-http
- 在你的
http服务中的pom.xml文件 新增如下依赖:
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-client-springmvc</artifactId>
<version>${shenyu.version}</version>
</dependency>- 在 application.yaml 增加如下配置:
shenyu:
register:
registerType: http #zookeeper #etcd #nacos #consul
serverLists: http://localhost:9095 #localhost:2181 #http://localhost:2379 #localhost:8848
props:
username: admin
password: 123456
client:
http:
props:
contextPath: /http
appName: http
# port: 8189 - 在你的
-
SpringMvc用户可以参考:shenyu-examples-springmvc
在你的
http