springboot项目http协议转https协议
最终效果图片(https://电脑ip:端口/)
![](https://i-blog.csdnimg.cn/blog_migrate/a7bbb456772e4c043b639913a014edac.png)
springBoot项目实现步骤:
修改application.yml 即可
server:
port: 8848
ssl:
key-store: classpath:88888888.com.pfx #证书
key-store-password: 8888888 #密码
key-store-type: PKCS12
keyAliss: tomcat
附加一个类似tomcat 修改端口访问效果的小功能(所有访问8888和8848端口都会转到8848端口)
XXXapplication.java 主启动类中添加
@Bean
public Connector connector(){
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(8888);
connector.setSecure(false);
connector.setRedirectPort(8848);
return connector;
}