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 ''