Spring Cloud 微服务开发:入门、进阶与源码剖析 —— 9.2 Spring Cloud Gateway 启动访问流程源码解析

9.2 Spring Cloud Gateway 启动访问流程源码解析

网关启动第一步就是去加载config包下的几个类,如图9-3:

图9-3

做网关开发时,不用引入spring-boot-starter-web依赖,因为gateway是基于spring-webflux开发的,它依赖的DispatcherHandler就和我们web里的DispatcherServlet一样的功能。org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration类,就向我们解释了为什么不需要引入。它在GatewayAutoConfiguration之前加载,如果DispatcherServlet存在的话,就会给予警告;如果DispatcherHandler不在的话,也会给予警告。

@Configuration
@AutoConfigureBefore(GatewayAutoConfiguration.

猜你喜欢

转载自blog.csdn.net/meteor_93/article/details/104433500