标签:strong 项目 set new 空格 rri dir proc post
springboot项目jar包方式启动通用
1.证书放入资源文件夹
2.server 添加 ssl配置
踩坑点: key-store: classpath后面的冒号需要紧跟着classpath,不能有空格, 这里我折腾了1个小时多才发现
3. 原有http访问跳转到https
@Bean public Connector connector(){
//此函数中的80、443端口仅测试使用。 实际情况可读取配置后修改
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setScheme("http"); connector.setPort(80); connector.setSecure(false); connector.setRedirectPort(443); 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; }
SpringCloud踩坑日记 (2) - zuul开启https
标签:strong 项目 set new 空格 rri dir proc post
原文地址:https://www.cnblogs.com/xdxy/p/9962634.html