You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Getting Started
  2. ### Reference Documentation
  3. For further reference, please consider the following sections:
  4. * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
  5. * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.2.RELEASE/maven-plugin/)
  6. 1. 首先使用jdk 自带的keytool 命令生成证书(一般在用户目录下C:\Users\Administrator\server.keystore) 复制到项目中
  7. > 自己生成的证书浏览器会有危险提示,去ssl网站上使用金钱申请则不会
  8. ![ssl 命令截图](ssl.png)
  9. 2. 然后添加配置
  10. ```yml
  11. server:
  12. ssl:
  13. # 证书路径
  14. key-store: spring-boot-demo-https\src\main\resources\server.keystore
  15. key-alias: tomcat
  16. enabled: true
  17. key-store-type: JKS
  18. #与申请时输入一致
  19. key-store-password: 123456
  20. # 浏览器默认端口 和 80 类似
  21. port: 443
  22. #debug: true
  23. ```
  24. 3. 需要与http 自动跳转再添加bean
  25. ```java
  26. @Bean
  27. public Connector connector(){
  28. Connector connector=new Connector("org.apache.coyote.http11.Http11NioProtocol");
  29. connector.setScheme("http");
  30. connector.setPort(80);
  31. connector.setSecure(false);
  32. connector.setRedirectPort(443);
  33. return connector;
  34. }
  35. @Bean
  36. public TomcatServletWebServerFactory tomcatServletWebServerFactory(Connector connector){
  37. TomcatServletWebServerFactory tomcat=new TomcatServletWebServerFactory(){
  38. @Override
  39. protected void postProcessContext(Context context) {
  40. SecurityConstraint securityConstraint=new SecurityConstraint();
  41. securityConstraint.setUserConstraint("CONFIDENTIAL");
  42. SecurityCollection collection=new SecurityCollection();
  43. collection.addPattern("/*");
  44. securityConstraint.addCollection(collection);
  45. context.addConstraint(securityConstraint);
  46. }
  47. };
  48. tomcat.addAdditionalTomcatConnectors(connector);
  49. return tomcat;
  50. }
  51. ```

一个用来深度学习并实战 spring boot 的项目,目前总共包含 66 个集成demo,已经完成 55 个。