|
@ -28,8 +28,8 @@ public class ApplicationStart implements ServletContextListener {
|
|
|
@Override
|
|
|
public void contextInitialized(ServletContextEvent context) {
|
|
|
try {
|
|
|
String home = System.getProperty("catalina.home").replace('\\','/');
|
|
|
String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
|
|
|
String home = System.getProperty("catalina.home").replace('\\', '/');
|
|
|
String homeUrl = home.substring(0, home.lastIndexOf('/') + 1);
|
|
|
dbConfig(homeUrl);
|
|
|
sslConfig(homeUrl);
|
|
|
|
|
@ -41,33 +41,35 @@ public class ApplicationStart implements ServletContextListener {
|
|
|
|
|
|
/**
|
|
|
* 修改微服务连接ssl文件
|
|
|
*
|
|
|
* @param homeUrl
|
|
|
*/
|
|
|
private void sslConfig(String homeUrl) throws Exception {
|
|
|
InputStream in = this.getClass().getResourceAsStream("/config/http.properties");
|
|
|
prop.load(in);
|
|
|
String configPath = this.getClass().getClassLoader().getResource("/").getPath()+ "config/http.properties";
|
|
|
String configPath = this.getClass().getClassLoader().getResource("/").getPath() + "config/http.properties";
|
|
|
OutputStream fos = new FileOutputStream(configPath);
|
|
|
String url = homeUrl+"ssl/tomcat.keystore";
|
|
|
prop.setProperty("sslKeystore",url);
|
|
|
prop.store(fos,"last update");
|
|
|
String url = homeUrl + "ssl/tomcat.keystore";
|
|
|
prop.setProperty("sslKeystore", url);
|
|
|
prop.store(fos, "last update");
|
|
|
in.close();
|
|
|
fos.close();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改数据库连接字符串
|
|
|
*
|
|
|
* @param homeUrl
|
|
|
*/
|
|
|
private void dbConfig(String homeUrl) throws Exception {
|
|
|
InputStream in = this.getClass().getResourceAsStream("/config/dbhelper.properties");
|
|
|
prop.load(in);
|
|
|
String configPath = this.getClass().getClassLoader().getResource("/").getPath()+ "config/dbhelper.properties";
|
|
|
String configPath = this.getClass().getClassLoader().getResource("/").getPath() + "config/dbhelper.properties";
|
|
|
OutputStream fos = new FileOutputStream(configPath);
|
|
|
String url = homeUrl+"db/localDB.db";
|
|
|
prop.setProperty("defaultName","miniResourceDB");
|
|
|
prop.setProperty("defaultUri","jdbc:sqlite://"+url);
|
|
|
prop.store(fos,"last update");
|
|
|
String url = homeUrl + "db/localDB.db";
|
|
|
prop.setProperty("defaultName", "miniResourceDB");
|
|
|
prop.setProperty("defaultUri", "jdbc:sqlite://" + url);
|
|
|
prop.store(fos, "last update");
|
|
|
in.close();
|
|
|
fos.close();
|
|
|
}
|
|
@ -78,4 +80,7 @@ public class ApplicationStart implements ServletContextListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
System.out.println(520 / 3);
|
|
|
}
|
|
|
}
|