springboot 同时启用http/https

1. 启用HTTPS

修改配置

  • application.yml
server:
# port: 80
  port: 443
  ssl:
    enabled: true
    key-store: /key_store.jks
    key-store-password: key_store_pwd

2. 添加http协议连接器

增加JAVA配置

@Bean
public ServletWebServerFactory servletWebServerFactory() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
    connector.setPort(80);
    tomcat.addAdditionalTomcatConnectors(connector);
    return tomcat;
}

posted on 2022-04-11 22:38  路过君  阅读(0)  评论(0编辑  收藏  举报

导航