El Lord Code El Lord Code - 2 months ago 39x
Java Question

Enable HTTP 2.0 for Undertow in Spring Boot

I wonder how I can enable the HTTP 2.0 for Undertow using Spring Boot, I monitored the protocol and currently HTTPS is using 1.1.

Is there any property for it? Or should I create a EmbeddedServletContainerFactory with this option.



You need to add the following bean to the configuration

    UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
        UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
                builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
        return factory;

Then start the application with alpn-boot-8.1.9.v20160720.jar in the boot class path

java -Xbootclasspath/p:<<location>>/alpn-boot-8.1.9.v20160720.jar -jar <<your application>>