Springboot starts http2

hexiaoming123 2021-02-22 23:23:14
springboot starts http2 http


http2 Need to be in https Open on the basis of therefore You need a certificate here

#Java It comes with a key management tool --keytool, Use this tool , We can generate a self signed certificate 
C:\project\github\spring-component-use-demo>keytool -genkey -alias undertow -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -dname "CN=li, OU=zelin, O=zelin, L=bj, ST= bj, C=CN"
 Enter the keystore password :
 Enter the new password again :
# The password here needs to be configured later in the project The generated keystore.p12 Just put it in the root directory of the project 

Project configuration

# Port number 
server.port=443
# To configure ssl (https)
#keystore.p12 The path of 
server.ssl.key-store=keystore.p12
# The password you entered before 
server.ssl.key-password=lizelin
server.ssl.key-store-password=lizelin
# To configure ssl (https) end
# Use http2
server.http2.enabled=true

controller

@RestController
@RequestMapping
public class Http2Controller {

@GetMapping
public String demo() {

return "demo";
}
}

result

https://127.0.0.1
Name Status Protocol
127.0.0.1 200 h2

http turn https To configure ( The configuration here is only suitable for Tomcat)

@Configuration
public class Http2HttpsConfig {

@Bean
public Connector connector(@Value("${server.port}") int port){

Connector connector=new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(80);
connector.setSecure(false);
connector.setRedirectPort(port);
return connector;
}
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory(Connector connector){

TomcatServletWebServerFactory tomcat=new TomcatServletWebServerFactory(){

@Override
protected void postProcessContext(Context context) {

SecurityConstraint securityConstraint=new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection=new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(connector);
return tomcat;
}
}

spring boot The default is tomcat( I won't support it http2), We need to put tomcat remove , And then change to undertow.

版权声明
本文为[hexiaoming123]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/02/20210222135129528v.html

  1. Vue3元件(九)Vue + element-Plus + json = 動態渲染的表單控制元件
  2. 我的 HTTP/1.1 好慢啊!
  3. Vue為何採用非同步渲染
  4. The response status was 0. Check out the W3C XMLHttpRequest Level 2 spec for
  5. Front end monastery
  6. How to quickly understand a new front end project?
  7. webpack4.X核心工具库之tapable实例对象Hook
  8. webpack4.X核心工具库之tapable实例对象Hook
  9. C++使用libcurl进行http通讯
  10. Can be directly used in HTML special character table Unicode character set
  11. C++使用libcurl进行http通讯
  12. Java traverses list < string > and takes out the string elements in it, and splices them with ","
  13. Self taught web front end more than two months, talk about my harvest and progress, learning summary
  14. vue 中使用 css 变量
  15. 深入了解React中state和props的更新
  16. 百度分享不支持https的解决方案
  17. [practical] ABAP mail sending (HTML + attachment)
  18. [practical] ABAP mail sending (HTML + attachment)
  19. Teach you how to select products with less profit and competition in Amazon Product Development (1)
  20. 【微前端】微前端最终章-qiankun指南以及微前端整体探索
  21. 【微前端】微前端最终章-qiankun指南以及微前端整体探索
  22. Vue-Cli 创建vue3项目
  23. Go in the front of the progress of u boot v7.0 U disk boot disk production tools
  24. 使用NTLM的windows身份验证的nginx反向代理
  25. Rust教程:针对JavaScript开发人员的Rust简介
  26. 使用 Serverless Framework 部署个人博客到腾讯云
  27. #研發解決方案#易車前端監控系統
  28. Vue changes localhost to IP address and cannot access
  29. JavaScript进阶学习
  30. HTML5 from entry to proficient, realize annual salary 10W +, zero basic students must see
  31. Vue:vuex状态数据持久化插件vuex-persistedstate
  32. Vue source code analysis - start
  33. Vue -- the child component calls the method of the parent component and passes parameters --- props
  34. React-Native 获取设备当前网络状态 NetInfo
  35. 高性能 Nginx HTTPS 调优 - 如何为 HTTPS 提速 30%
  36. How to learn HTML5? How can Xiaobai start HTML5 quickly?
  37. HTML + CSS detailed tutorial, this article is enough, but also quickly save
  38. JavaScript高级:JavaScript面向对象,JavaScript内置对象,JavaScript BOM,JavaScript封装
  39. Why Vue uses asynchronous rendering
  40. JavaScript高级:JavaScript面向对象,JavaScript内置对象,JavaScript BOM,JavaScript封装
  41. vue判断elementui中el-form是否更新变化,变化就提示是否保存,没变就直接离开
  42. 算法题:两数之和——JavaScript及Java实现
  43. 高性能 Nginx HTTPS 调优
  44. Why Vue uses asynchronous rendering
  45. day 31 jQuery进阶
  46. day 30 jQuery
  47. CSS whimsy -- using background to create all kinds of wonderful backgrounds
  48. Why are more and more people learning front end?
  49. What do you do with 4K front-end development?
  50. 8 years of front-end development knowledge precipitation (do not know how many words, keep writing it...)
  51. What is the annual salary of a good web front end?
  52. Front end novice tutorial! How to get started with web front end
  53. Will the front end have a future?
  54. Is the front end hard to learn?
  55. Seven new Vue combat skills to improve efficiency in 2021!
  56. Is front end learning difficult?
  57. How about the process of Web front-end development and self-study?
  58. Front end learning route from zero basis to proficient
  59. What is the basis of learning front end?
  60. What knowledge points need to be learned for self-study front end? How long can I become a front-end Engineer?