我正在使用带有嵌入式Undertow服务器1.4的Spring boot 1.5.12(JDK 8),我使用'server.https.enabled:true'在我的属性中启用了http2协议,但它似乎不起作用。我还确保了与自签名证书的连接。当我在浏览器上加载我的应用程序(Angular 5)时,我仍然得到http / 1.1协议。
以下是我在SpringBootApplication类中的内容:
@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文件
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}
还有什么我需要配置的吗?
提前致谢
答案 0 :(得分:0)
尝试将以下bean添加到您的配置中:
@Bean
UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
factory.addBuilderCustomizers(
builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
return factory;
}
答案 1 :(得分:0)
属性server.http2.enabled
在Spring Boot 1.5.13中不存在。参见this