🤗 ApiHug × {Postman|Swagger|Api...} = 快↑ 准√ 省↓
- GitHub - apihug/apihug.com: All abou the Apihug
- apihug.com: 有爱,有温度,有质量,有信任
- ApiHug - API design Copilot - IntelliJ IDEs Plugin | Marketplace
The Next Generation API Development Platform - ApiHug
极简版初始化过程
- ReactiveWebServerFactoryConfiguration
- NettyReactiveWebServerFactory
- AnnotationConfigReactiveWebServerApplicationContext
- ReactiveWebServerApplicationContext
SpringApplicationAnnotationConfigReactiveWebServerApplicationContextNettyReactiveWebServerFactoryWebServerWebServerStartStopLifecycle封装 HttpHandler创建 HttpServeronRefresh 启动应用上下文createWebServer 创建Web服务new 创建封装WebServer到WebServerStartStopLifecycle控制start(启动)stop(关闭)SpringApplicationAnnotationConfigReactiveWebServerApplicationContextNettyReactiveWebServerFactoryWebServerWebServerStartStopLifecycle
#触发
- ReactiveWebServerApplicationContext#onRefresh
- ReactiveWebServerApplicationContext#createWebServer
private void createWebServer() {WebServerManager serverManager = this.serverManager;if (serverManager == null) {StartupStep createWebServer = this.getApplicationStartup().start("spring.boot.webserver.create");String webServerFactoryBeanName = getWebServerFactoryBeanName();ReactiveWebServerFactory webServerFactory = getWebServerFactory(webServerFactoryBeanName);createWebServer.tag("factory", webServerFactory.getClass().toString());boolean lazyInit = getBeanFactory().getBeanDefinition(webServerFactoryBeanName).isLazyInit();this.serverManager = new WebServerManager(this, webServerFactory, this::getHttpHandler, lazyInit); //【1】getBeanFactory().registerSingleton("webServerGracefulShutdown",new WebServerGracefulShutdownLifecycle(this.serverManager.getWebServer()));getBeanFactory().registerSingleton("webServerStartStop",new WebServerStartStopLifecycle(this.serverManager)); //【2】createWebServer.end();}initPropertySources();
}
- 【1】 创建一个 WebServerManager
- 【2】 封装到: WebServerStartStopLifecycle, 让外围流程控制启动顺序:
@Override
public int getPhase() {return Integer.MAX_VALUE - 1;
}
Spring Boot 配置元信息揭秘, 描述一般spring auto configuration 启动过程!
#WebFlux 自动配置
org.springframework.boot.autoconfigure.web.reactive.ReactiveMultipartAutoConfiguration=
org.springframework.boot.autoconfigure.web.reactive.ReactiveMultipartAutoConfiguration.ConditionalOnClass=org.springframework.http.codec.multipart.DefaultPartHttpMessageReader,org.springframework.web.reactive.config.WebFluxConfigurer
org.springframework.boot.autoconfigure.web.reactive.ReactiveMultipartAutoConfiguration.ConditionalOnWebApplication=REACTIVEorg.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration=
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration.AutoConfigureOrder=-2147483648
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration.ConditionalOnClass=org.springframework.http.ReactiveHttpInputMessage
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration.ConditionalOnWebApplication=REACTIVEorg.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryConfiguration$EmbeddedNetty=
org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryConfiguration$EmbeddedNetty.ConditionalOnClass=reactor.netty.http.server.HttpServerorg.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration=
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration.AutoConfigureAfter=org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,org.springframework.boot.autoconfigure.web.reactive.ReactiveMultipartAutoConfiguration,org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,org.springframework.boot.autoconfigure.web.reactive.WebSessionIdResolverAutoConfigurationorg.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration.AutoConfigureOrder=-2147483638
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration.ConditionalOnClass=org.springframework.web.reactive.config.WebFluxConfigurer
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration.ConditionalOnWebApplication=REACTIVE
#参考
- spring-framework | spring-webflux 源码open in new window
- Web on Reactive Stack 官方文档open in new window
- Spring-boot | web reactive 文档open in new window
- 第二学院 reactive 例子代码open in new window
- 第二学院 reactive 文档open in new window
- spring security reactive 安全open in new window
- Spring Cloud Gateway 最佳示范open in new window
- baeldung webfluxopen in new window
- baeldung websoketopen in new window
- baeldung reactive codeopen in new window
rsocket