解决打包后找不到jks文件的问题
This commit is contained in:
+22
-3
@@ -1,23 +1,30 @@
|
|||||||
package com.jero.config;
|
package com.jero.config;
|
||||||
|
|
||||||
|
import com.jero.modules.project.service.impl.ProjectLawsInventoryEOServiceImpl;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.catalina.connector.Connector;
|
import org.apache.catalina.connector.Connector;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
//@PropertySource("classpath:config/tomcat.https.properties")
|
//@PropertySource("classpath:config/tomcat.https.properties")
|
||||||
@ConfigurationProperties(prefix = "jero.tomcat.https")
|
@ConfigurationProperties(prefix = "jero.tomcat.https")
|
||||||
@Data
|
@Data
|
||||||
public class TomcatSslConnectorProperties {
|
public class TomcatSslConnectorProperties {
|
||||||
|
|
||||||
|
@Value("${jero.path.upload}")
|
||||||
|
private String tempStoreJks;
|
||||||
|
|
||||||
private Integer port;
|
private Integer port;
|
||||||
private Boolean ssl = true;
|
private Boolean ssl = true;
|
||||||
private Boolean secure = true;
|
private Boolean secure = true;
|
||||||
private String scheme = "https";
|
private String scheme = "https";
|
||||||
private File keystore;
|
private String keystore;
|
||||||
private String keystorePassword;
|
private String keystorePassword;
|
||||||
private String keystoreType;
|
private String keystoreType;
|
||||||
//这里为了节省空间,省略了getters和setters,读者在实践的时候要加上
|
//这里为了节省空间,省略了getters和setters,读者在实践的时候要加上
|
||||||
@@ -36,8 +43,20 @@ public class TomcatSslConnectorProperties {
|
|||||||
connector.setProperty("SSLEnabled", ssl.toString());
|
connector.setProperty("SSLEnabled", ssl.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keystore != null && keystore.exists()) {
|
InputStream inputStream = ProjectLawsInventoryEOServiceImpl.class.getClassLoader().getResourceAsStream(keystore);
|
||||||
connector.setProperty("keystoreFile", keystore.getAbsolutePath());
|
|
||||||
|
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("keystorePass", keystorePassword);
|
||||||
connector.setProperty("keystoreType", keystoreType);
|
connector.setProperty("keystoreType", keystoreType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ jero :
|
|||||||
secure: true
|
secure: true
|
||||||
scheme: https
|
scheme: https
|
||||||
ssl: true
|
ssl: true
|
||||||
keystore: classpath:grp.jks
|
keystore: grp.jks
|
||||||
keystorePassword: 501937
|
keystorePassword: 501937
|
||||||
keystoreType: JKS
|
keystoreType: JKS
|
||||||
shiro:
|
shiro:
|
||||||
|
|||||||
Reference in New Issue
Block a user