编程语言
首页 > 编程语言> > Soul网关源码阅读05

Soul网关源码阅读05

作者:互联网

结合springcloud插件,发起http请求soul网关,体验springcloud代理

一、环境准备

1、soul-bootstrap 引入网关springCloud的插件支持

<!--soul springCloud plugin start-->
  <dependency>
       <groupId>org.dromara</groupId>
       <artifactId>soul-spring-boot-starter-plugin-springcloud</artifactId>
        <version>${last.version}</version>
  </dependency>
  <dependency>
       <groupId>org.dromara</groupId>
       <artifactId>soul-spring-boot-starter-plugin-httpclient</artifactId>
       <version>${last.version}</version>
   </dependency>
   <!--soul springCloud plugin end-->
   <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-commons</artifactId>
        <version>2.2.0.RELEASE</version>
   </dependency>
   <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        <version>2.2.0.RELEASE</version>
   </dependency>
 <dependency>
       <groupId>org.springframework.cloud</groupId>
       <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
       <version>2.2.0.RELEASE</version>
  </dependency>
   eureka:
     client:
       serviceUrl:
         defaultZone: http://localhost:8761/eureka/ # 你的eureka地址
     instance:
       prefer-ip-address: true

2、soul-examples --> soul-examples-springcloud 服务

<dependency>
    <groupId>org.dromara</groupId>
    <artifactId>soul-spring-boot-starter-client-springcloud</artifactId>
    <version>${soul.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>${spring-cloud.version}</version>
</dependency>
eureka:
  client:
    serviceUrl:
      defaultZone:http://localhost:8761/eureka/
soul:
  springcloud:
    admin-url:http://localhost:9095
    context-path:/springcloud

3、soul-admin 插件设置

soul-admin --> 插件管理 --> springCloud,设置为开启。
在这里插入图片描述
二、启动服务

soul-examples --> soul-examples-springcloud 服务接口注册到网关打印的成功信息

2021-01-19 15:37:58.304  INFO 82962 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils  : springCloud client register success: {"appName":"springCloud-test","context":"/springcloud","path":"/springcloud/order/path/**","pathDesc":"","rpcType":"springCloud","ruleName":"/springcloud/order/path/**","enabled":true} 
2021-01-19 15:37:58.322  INFO 82962 --- [pool-1-thread-1] o.d.s.client.common.utils.RegisterUtils  : springCloud client register success: {"appName":"springCloud-test","context":"/springcloud","path":"/springcloud/order/path/**/name","pathDesc":"","rpcType":"springCloud","ruleName":"/springcloud/order/path/**/name","enabled":true} 

查看 soul-admin 接口注册信息在这里插入图片描述
三、测试

通过网关请求 springcloud 接口,请求成功在这里插入图片描述

未完待续

标签:网关,springCloud,springcloud,Soul,eureka,源码,examples,soul,cloud
来源: https://blog.csdn.net/liquan961646757/article/details/112854146