• springboot嵌入式Servlet容器自动配置原理


    @Configuration(proxyBeanMethods = false)
    @ConditionalOnWebApplication
    @EnableConfigurationProperties(ServerProperties.class)
    public class EmbeddedWebServerFactoryCustomizerAutoConfiguration {
    
        /**
         * 如果容器中有Tomcat.class就使用tomcat容器
         */
        @Configuration(proxyBeanMethods = false)
        @ConditionalOnClass({ Tomcat.class, UpgradeProtocol.class })
        public static class TomcatWebServerFactoryCustomizerConfiguration {
    
            @Bean
            public TomcatWebServerFactoryCustomizer tomcatWebServerFactoryCustomizer(Environment environment,
                    ServerProperties serverProperties) {
                return new TomcatWebServerFactoryCustomizer(environment, serverProperties);
            }
    
        }
    
        /**
         * 如果容器中有Jetty
         */
        @Configuration(proxyBeanMethods = false)
        @ConditionalOnClass({ Server.class, Loader.class, WebAppContext.class })
        public static class JettyWebServerFactoryCustomizerConfiguration {
    
            @Bean
            public JettyWebServerFactoryCustomizer jettyWebServerFactoryCustomizer(Environment environment,
                    ServerProperties serverProperties) {
                return new JettyWebServerFactoryCustomizer(environment, serverProperties);
            }
    
        }
    
        /**
         * 如果容器中有Undertow就加载Undertow
         */
        @Configuration(proxyBeanMethods = false)
        @ConditionalOnClass({ Undertow.class, SslClientAuthMode.class })
        public static class UndertowWebServerFactoryCustomizerConfiguration {
    
            @Bean
            public UndertowWebServerFactoryCustomizer undertowWebServerFactoryCustomizer(Environment environment,
                    ServerProperties serverProperties) {
                return new UndertowWebServerFactoryCustomizer(environment, serverProperties);
            }
    
        }
    
        /**
         * Nested configuration if Netty is being used.
         */
        @Configuration(proxyBeanMethods = false)
        @ConditionalOnClass(HttpServer.class)
        public static class NettyWebServerFactoryCustomizerConfiguration {
    
            @Bean
            public NettyWebServerFactoryCustomizer nettyWebServerFactoryCustomizer(Environment environment,
                    ServerProperties serverProperties) {
                return new NettyWebServerFactoryCustomizer(environment, serverProperties);
            }
    
        }
    
    }

    springboot-web模块默认依赖tomca,修改内置servlet,引入其他依赖并删除tomcat依赖就可以

  • 相关阅读:
    WebFrom 复杂控件
    WebFrom 简单控件
    WinForm开发控件集合
    ListView 控件操作
    窗体类型
    WEBFORM--第一讲
    display:inline/block/inline-block
    WINFORM--第五讲(窗体类型)
    WINFORM--第四讲(布局)
    WINFORM--第三讲(下拉列表)
  • 原文地址:https://www.cnblogs.com/vegeta-xiao/p/12509962.html
Copyright © 2020-2023  润新知