Merge remote-tracking branch 'origin/fix_bug_first_stage' into fix_bug_first_stage
This commit is contained in:
-76
@@ -1,76 +0,0 @@
|
|||||||
package com.jero.config.init;
|
|
||||||
|
|
||||||
import org.apache.catalina.Context;
|
|
||||||
import org.apache.catalina.connector.Connector;
|
|
||||||
import org.apache.coyote.http11.Http11NioProtocol;
|
|
||||||
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
|
||||||
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
|
||||||
import org.apache.tomcat.util.scan.StandardJarScanner;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: TomcatFactoryConfig
|
|
||||||
* @author: scott
|
|
||||||
* @date: 2021年01月25日 11:40
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class TomcatFactoryConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tomcat-embed-jasper引用后提示jar找不到的问题
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public TomcatServletWebServerFactory tomcatFactory() {
|
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() {
|
|
||||||
@Override
|
|
||||||
protected void postProcessContext(Context context) {
|
|
||||||
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
factory.addConnectorCustomizers(connector -> {
|
|
||||||
connector.setProperty("relaxedPathChars", "[]{}");
|
|
||||||
connector.setProperty("relaxedQueryChars", "[]{}");
|
|
||||||
});
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO 配置https证书 部署服务器的时候解开。
|
|
||||||
/* @Value("${server.port}")
|
|
||||||
private String serverPortHttp;
|
|
||||||
@Value("${server.port-https}")
|
|
||||||
private String serverPortHttps;
|
|
||||||
@Bean
|
|
||||||
public TomcatServletWebServerFactory tomcatFactory() {
|
|
||||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() {
|
|
||||||
@Override
|
|
||||||
protected void postProcessContext(Context context) {
|
|
||||||
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
|
|
||||||
|
|
||||||
SecurityConstraint securityConstraint = new SecurityConstraint();
|
|
||||||
securityConstraint.setUserConstraint("CONFIDENTIAL");
|
|
||||||
SecurityCollection securityCollection = new SecurityCollection();
|
|
||||||
securityCollection.addPattern("/*");
|
|
||||||
securityConstraint.addCollection(securityCollection);
|
|
||||||
context.addConstraint(securityConstraint);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
factory.addConnectorCustomizers(connector -> {
|
|
||||||
connector.setProperty("relaxedPathChars", "[]{}");
|
|
||||||
connector.setProperty("relaxedQueryChars", "[]{}");
|
|
||||||
});
|
|
||||||
factory.addAdditionalTomcatConnectors(redirectConnector());
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Connector redirectConnector() {
|
|
||||||
Connector connector = new Connector(Http11NioProtocol.class.getName());
|
|
||||||
connector.setScheme("http");
|
|
||||||
connector.setPort(Integer.parseInt(serverPortHttp));
|
|
||||||
connector.setSecure(false);
|
|
||||||
connector.setRedirectPort(Integer.parseInt(serverPortHttps));
|
|
||||||
return connector;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package com.jero.config;
|
||||||
|
|
||||||
|
import com.jero.modules.project.service.impl.ProjectLawsInventoryEOServiceImpl;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.catalina.connector.Connector;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
//@PropertySource("classpath:config/tomcat.https.properties")
|
||||||
|
@ConfigurationProperties(prefix = "jero.tomcat.https")
|
||||||
|
@Data
|
||||||
|
public class TomcatSslConnectorProperties {
|
||||||
|
|
||||||
|
@Value("${jero.path.upload}")
|
||||||
|
private String tempStoreJks;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
private Boolean ssl = true;
|
||||||
|
private Boolean secure = true;
|
||||||
|
private String scheme = "https";
|
||||||
|
private String 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
InputStream inputStream = ProjectLawsInventoryEOServiceImpl.class.getClassLoader().getResourceAsStream(keystore);
|
||||||
|
|
||||||
|
String keystorePath = tempStoreJks + File.separator + keystore;
|
||||||
|
File keystoreFile = new File(keystorePath);
|
||||||
|
if (!keystoreFile.exists()){
|
||||||
|
try {
|
||||||
|
FileUtils.copyInputStreamToFile(inputStream, keystoreFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keystoreFile != null && keystoreFile.exists()) {
|
||||||
|
connector.setProperty("keystoreFile", keystorePath);
|
||||||
|
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
|
enabled: true
|
||||||
min-response-size: 1024
|
min-response-size: 1024
|
||||||
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
|
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:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
@@ -209,6 +203,15 @@ jero :
|
|||||||
exportPdfTempPath: D://opt//exportPdfTemp/
|
exportPdfTempPath: D://opt//exportPdfTemp/
|
||||||
#仿宋体字体文件路径 设置
|
#仿宋体字体文件路径 设置
|
||||||
simfangFontFilePath: D://opt//simfangFontFilePath//simfang.ttf
|
simfangFontFilePath: D://opt//simfangFontFilePath//simfang.ttf
|
||||||
|
tomcat:
|
||||||
|
https:
|
||||||
|
port: 8089
|
||||||
|
secure: true
|
||||||
|
scheme: https
|
||||||
|
ssl: true
|
||||||
|
keystore: grp.jks
|
||||||
|
keystorePassword: 501937
|
||||||
|
keystoreType: JKS
|
||||||
shiro:
|
shiro:
|
||||||
excludeUrls: /test/jeroDemo/demo3,/test/jeroDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
|
excludeUrls: /test/jeroDemo/demo3,/test/jeroDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
|
||||||
#阿里云oss存储配置
|
#阿里云oss存储配置
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user