lyso

application.yml配置文件参考配置:

.jks格式 key-store-type: JKS,    .pfx、.p12格式 key-store-type: PKCS12

server:
  port: 443
  servlet:
    context-path: /
  ssl:
    protocol: TLS
    key-store: classpath:www.javays.com.jks
    key-store-password: 0qi591u7vpgo
    key-store-type: JKS

同时支持http、https两个协议启动类配置如下:

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
        tomcat.addAdditionalTomcatConnectors(createStandardConnector());
        return tomcat;
    }

    private Connector createStandardConnector() {
        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        connector.setPort(8080);//http访问端口
        return connector;
    }

}

 

启动 springboot 之后就会看到下面的同时支持两个协议日志

Tomcat started on port(s): 443 (https) 8080 (http) with context path ''

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-11-21
猜你喜欢
  • 2021-04-26
  • 2021-11-20
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案