首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring boot使能http/2协议

Spring boot使能http/2协议
EN

Stack Overflow用户
提问于 2018-05-22 22:32:58
回答 2查看 3K关注 0票数 3

我正在使用Spring boot 1.5.12 (JDK8)和嵌入式Undertow服务器1.4,我已经在我的属性中使用了'server.https.enabled: true‘来启用http2协议,但它似乎不起作用。我也有自己签署的证书安全连接。当我在浏览器上加载我的应用程序(Angular 5)时,我仍然得到http/1.1协议。

下面是我的SpringBootApplication类中的内容:

代码语言:javascript
复制
@SpringBootApplication
@EnableEurekaClient
@EnableOAuth2Sso
public class Application extends WebSecurityConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        //some authorization configuration
    }
}

Application.properties文件

代码语言:javascript
复制
security:
  require-ssl: true
server:
  ssl:
    enabled: true
  http2:
    enabled: true
   port: 8085
    ssl:
      key-store: classpath: keystore.p12
      key-store-type: PKCS12
      key-alias: devel
      key-store-password: pass
      key-password: pass
eureka:
  client:
    serviceUrl:
      defaultZone: https://localhost:8761/eureka
  instance:
    preferIpAddress: false
    securePortEnabled: true
    securePort: ${server.port}

还有什么我需要配置的吗?

提前感谢

EN

回答 2

Stack Overflow用户

发布于 2018-05-22 23:10:39

尝试将以下bean添加到配置中:

代码语言:javascript
复制
@Bean
UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
    UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
    factory.addBuilderCustomizers(
            builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
    return factory;
}
票数 0
EN

Stack Overflow用户

发布于 2019-04-04 17:39:16

属性server.http2.enabled在spring boot 1.5.13中不存在。请参阅this

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50470332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档