为了满足客户的需求,
首先cmd进入jdk的bin目录
keytool -genkey -v -alias testKey -keyalg RSA -validity 3650 -keystore C:\jdk证书\test.keystore
生成好之后把生成好的文件复制到resources目录下
application.properties
#是否开启缓存,开发时可以设置为 false,默认为 true
spring.thymeleaf.cache=false
#检查模版是否存在,默认为 true
spring.thymeleaf.check-template=true
#检查模版位置是否存在,默认为 true
spring.thymeleaf.check-template-location=true
#模版文件编码
spring.thymeleaf.encoding=UTF-8
#模版文件位置
spring.thymeleaf.prefix=classpath:/templates/
#Content-Type配置
spring.thymeleaf.servlet.content-type=text/html
#模版文件后缀
spring.thymeleaf.suffix=.html
spring.devtools.restart.enabled=true
server.port=8888
# 配置ssl证书
server.ssl.protocol=TLS
server.ssl.key-store=classpath:server.keystore
server.ssl.key-store-password=123456
#server.ssl.key-alias=tomcat
server.ssl.key-store-type=JKS
application.yml
server:
port:8443
ssl:
protocol: TLS
key-store: classpath:server.keystore
key-alias: tomcat
enabled:true
key-store-password: 123456
key-store-type: JKS
作者:kitter2020
链接:https://www.jianshu.com/p/b13e86242fe9
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
之后运行项目,恭喜,你已经成功运行https
在同一个项目配置http访问
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class HttpReq {
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(