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.
Tks,
You can enable HTTP/2 support in your Spring Boot application with the server. http2. enabled configuration property. This support depends on the chosen web server and the application environment, since that protocol is not supported out-of-the-box by JDK8.
Spring Boot Undertow Spring is a popular Java application framework and Spring Boot is an evolution of Spring that helps create stand-alone, production-grade Spring based applications easily.
To use Jetty in your Spring Boot application, we can use the spring-boot-starter-jetty starter. Spring Boot provides Tomcat and Jetty dependencies bundled together as separate starters to help make this process as easy as possible. Add the spring-boot-starter-jetty starter in your pom. xml file.
You need to add the following bean to the configuration
@Bean
UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
factory.addBuilderCustomizers(
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>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With