All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.youm.frame.webmvc.config.UndertowHttp2Configuration Maven / Gradle / Ivy

There is a newer version: 1.2.5
Show newest version
package me.youm.frame.webmvc.config;

import io.undertow.Undertow;
import me.youm.frame.webmvc.server.UndertowServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static io.undertow.UndertowOptions.ENABLE_HTTP2;

/**
 * @author youta
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Undertow.class)
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
public class UndertowHttp2Configuration {

    @Bean
    public WebServerFactoryCustomizer undertowHttp2WebServerFactoryCustomizer() {
        return factory -> factory.addBuilderCustomizers(builder -> builder.setServerOption(ENABLE_HTTP2, true));
    }

    /**
     * 实例化UndertowServerFactoryCustomizer,解决undertow启动提示warn的问题
     * @return UndertowServerFactoryCustomizer
     */
    @Bean
    public UndertowServerFactoryCustomizer undertowServerFactoryCustomizer() {
        return new UndertowServerFactoryCustomizer();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy