From 21a96ad20fd75e55d03c00af8df8adb039f0c77a Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 20 六月 2023 12:51:06 +0800
Subject: [PATCH] 修复通道刷新

---
 src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
index 990f003..886d6fa 100644
--- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
+++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
@@ -1,14 +1,63 @@
 package com.genersoft.iot.vmp;
 
-import java.util.logging.LogManager;
-
+import com.genersoft.iot.vmp.utils.GitUtil;
+import com.genersoft.iot.vmp.utils.SpringBeanFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import java.util.Collections;
+
+/**
+ * 鍚姩绫�
+ */
+@ServletComponentScan("com.genersoft.iot.vmp.conf")
 @SpringBootApplication
-public class VManageBootstrap extends LogManager {
+@EnableScheduling
+public class VManageBootstrap extends SpringBootServletInitializer {
+
+	private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);
+
+	private static String[] args;
+	private static ConfigurableApplicationContext context;
 	public static void main(String[] args) {
-		SpringApplication.run(VManageBootstrap.class, args);
+		VManageBootstrap.args = args;
+		VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
+		GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");
+		logger.info("鏋勫缓鐗堟湰锛� {}", gitUtil1.getBuildVersion());
+		logger.info("鏋勫缓鏃堕棿锛� {}", gitUtil1.getBuildDate());
+		logger.info("GIT鏈�鍚庢彁浜ゆ椂闂达細 {}", gitUtil1.getCommitTime());
+	}
+	// 椤圭洰閲嶅惎
+	public static void restart() {
+		context.close();
+		VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
+	}
+
+	@Override
+	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+		return application.sources(VManageBootstrap.class);
+	}
+
+	@Override
+	public void onStartup(ServletContext servletContext) throws ServletException {
+		super.onStartup(servletContext);
+
+		servletContext.setSessionTrackingModes(
+				Collections.singleton(SessionTrackingMode.COOKIE)
+		);
+		SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
+		sessionCookieConfig.setHttpOnly(true);
+
 	}
 }

--
Gitblit v1.8.0