在 Spring Boot 中为 Undertow 启用 HTTP 2.0 [英] Enable HTTP 2.0 for Undertow in Spring Boot

查看:69
本文介绍了在 Spring Boot 中为 Undertow 启用 HTTP 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用 Spring Boot 为 Undertow 启用 HTTP 2.0,我监控了协议,目前 HTTPS 使用的是 1.1.

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.

它有什么属性吗?或者我应该使用这个选项创建一个 EmbeddedServletContainerFactory.

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

谢谢,

推荐答案

需要在配置中加入如下bean

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;
    }

然后用启动类路径中的alpn-boot-8.1.9.v20160720.jar启动应用

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>>

这篇关于在 Spring Boot 中为 Undertow 启用 HTTP 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆