跳到主要内容

如何包含 Spring Cloud Gateway

DeepSeek V3 中英对照 How to Include Spring Cloud Gateway

要在项目中包含 Spring Cloud Gateway,请使用组 ID 为 org.springframework.cloud 和工件 ID 为 spring-cloud-starter-gateway 的 starter。有关如何使用当前 Spring Cloud Release Train 设置构建系统的详细信息,请参阅 Spring Cloud 项目页面

如果包含了 starter,但你不想启用网关,可以设置 spring.cloud.gateway.enabled=false

important

Spring Cloud Gateway 构建于 Spring BootSpring WebFluxProject Reactor 之上。因此,当你使用 Spring Cloud Gateway 时,许多熟悉的同步库(例如 Spring Data 和 Spring Security)和你所熟知的模式可能不再适用。如果你对这些项目不熟悉,我们建议你在使用 Spring Cloud Gateway 之前,先阅读它们的文档,以熟悉一些新的概念。

important

Spring Cloud Gateway 需要由 Spring Boot 和 Spring Webflux 提供的 Netty 运行时。它不能在传统的 Servlet 容器中运行,也不能构建为 WAR 文件。