zoukankan      html  css  js  c++  java
  • 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依赖就可以

  • 相关阅读:
    3-附1 ->和*的区别
    第2章 变量和基本类型
    第2章 变量和基本类型 附3---底层const和顶层const
    第2章 变量和基本类型 附2 --声明和定义的区别
    第2章 变量和基本类型 附1---变量和对象的区别
    第一章 开始
    1. 数据采集基础问题
    跟波利亚学解题---1
    [PTA]L2-001 紧急救援 (25 分)
    [图论]最短路计数(spfa)
  • 原文地址:https://www.cnblogs.com/vegeta-xiao/p/12509962.html
Copyright © 2011-2022 走看看