合并分支 'fix_bug_first_stage' 到 'master'

解决打包后找不到jks文件的问题

查看合并请求 laws-nio/laws-weilai!69
This commit is contained in:
肖文钰
2022-07-09 18:23:05 +08:00
2 changed files with 23 additions and 4 deletions
@@ -1,23 +1,30 @@
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 File keystore;
private String keystore;
private String keystorePassword;
private String keystoreType;
//这里为了节省空间,省略了getters和setters,读者在实践的时候要加上
@@ -36,8 +43,20 @@ public class TomcatSslConnectorProperties {
connector.setProperty("SSLEnabled", ssl.toString());
}
if (keystore != null && keystore.exists()) {
connector.setProperty("keystoreFile", keystore.getAbsolutePath());
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);
}
@@ -209,7 +209,7 @@ jero :
secure: true
scheme: https
ssl: true
keystore: classpath:grp.jks
keystore: grp.jks
keystorePassword: 501937
keystoreType: JKS
shiro: