单独启动http和https
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
package com.jero.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
//@PropertySource("classpath:config/tomcat.https.properties")
|
||||
@ConfigurationProperties(prefix = "jero.tomcat.https")
|
||||
@Data
|
||||
public class TomcatSslConnectorProperties {
|
||||
|
||||
private Integer port;
|
||||
private Boolean ssl = true;
|
||||
private Boolean secure = true;
|
||||
private String scheme = "https";
|
||||
private File keystore;
|
||||
private String keystorePassword;
|
||||
private String keystoreType;
|
||||
//这里为了节省空间,省略了getters和setters,读者在实践的时候要加上
|
||||
|
||||
public void configureConnector(Connector connector) {
|
||||
if (port != null) {
|
||||
connector.setPort(port);
|
||||
}
|
||||
if (secure != null) {
|
||||
connector.setSecure(secure);
|
||||
}
|
||||
if (scheme != null) {
|
||||
connector.setScheme(scheme);
|
||||
}
|
||||
if (ssl != null) {
|
||||
connector.setProperty("SSLEnabled", ssl.toString());
|
||||
}
|
||||
|
||||
if (keystore != null && keystore.exists()) {
|
||||
connector.setProperty("keystoreFile", keystore.getAbsolutePath());
|
||||
connector.setProperty("keystorePass", keystorePassword);
|
||||
connector.setProperty("keystoreType", keystoreType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.jero.config;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(TomcatSslConnectorProperties.class)
|
||||
public class TomcatWebConfiguration extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory servletContainer(TomcatSslConnectorProperties properties) {
|
||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||
factory.addAdditionalTomcatConnectors(createSslConnector(properties));
|
||||
return factory;
|
||||
}
|
||||
|
||||
private Connector createSslConnector(TomcatSslConnectorProperties properties) {
|
||||
Connector connector = new Connector();
|
||||
properties.configureConnector(connector);
|
||||
return connector;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,12 +12,6 @@ server:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
|
||||
##配置https证书 部署服务器的时候解开。
|
||||
# port-https: 8089 #自定义https端口
|
||||
# ssl:
|
||||
# key-store: classpath:bxxt.hzwlsoft.com.jks
|
||||
# key-store-password: w933m5y1kz0xj8w
|
||||
# key-store-type: JKS
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
@@ -209,6 +203,15 @@ jero :
|
||||
exportPdfTempPath: D://opt//exportPdfTemp/
|
||||
#仿宋体字体文件路径 设置
|
||||
simfangFontFilePath: D://opt//simfangFontFilePath//simfang.ttf
|
||||
tomcat:
|
||||
https:
|
||||
port: 8089
|
||||
secure: true
|
||||
scheme: https
|
||||
ssl: true
|
||||
keystore: classpath:grp.jks
|
||||
keystorePassword: 501937
|
||||
keystoreType: JKS
|
||||
shiro:
|
||||
excludeUrls: /test/jeroDemo/demo3,/test/jeroDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储配置
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user