• 如何在项目中引入Spring Cloud Gateway


    1.如何在项目中引入Spring Cloud Gateway

    如果你是使用的Maven管理的项目,在项目中添加group为org.springframework.cloud和artifact id为spring-cloud-starter-gateway的starter。如下面的Maven依赖所示:

    <!-- 配置Spring Boot -->
      <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.1.3.RELEASE</version>
      </parent>
    <!-- 配置Spring Clound 依赖管理 -->
      <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.RELEASE</version><!--注意这里面的版本,不同的版本,代码会有一些差别 --> <type>pom</type>                 <scope>import</scope> </dependency> </dependencies>   </dependencyManagement>   <dependencies> <dependency> <!--引入spring cloud gateway--> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency> </dependencies>

    如果你引入了spring cloud gateway的依赖,但是又不想使用spring cloud gateway生效,可以在application.yml配置中添加spring.cloud.gateway.enabled=false。

    注意,Spring Cloud Gateway需要Spring Boot和Spring Webflux提供的Netty的运行时环境,因此,它不可以打包成war包,也不可以在传统的Servlet容器(比如tomcat)中运行。所以Spring Cloud Gateway项目中不能依赖<artifactId>spring-boot-starter-web</artifactId>,要不然会报错。

    英语文档地址:https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.1.0.RELEASE/multi/multi_gateway-starter.html

    项目源码地址:https://gitee.com/wgslucky/SpringCloud   QQ交流群:677464431

  • 相关阅读:
    框架-.NET:ASP.NET Core
    框架-.NET:.NET Core
    框架-.NET:ASP.NET MVC
    框架-.Net:.NET框架
    资源-网址:网址杂项
    Webx.0-Web4.0:Web4.0
    第十一节,命名空间namespace
    UVA 1453
    IOS学习笔记44--ASIRequestHttp之BUG(一)
    poj 2391 (Floyd+最大流+二分)
  • 原文地址:https://www.cnblogs.com/wgslucky/p/11395932.html
Copyright © 2020-2023  润新知