2023-12-13 03:44:35 +00:00
|
|
|
|
package com.xdadan.erp;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xdadan.erp.common.utils.PropertyUtil;
|
|
|
|
|
|
import org.springframework.boot.WebApplicationType;
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
2024-12-31 08:00:59 +00:00
|
|
|
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
2023-12-13 03:44:35 +00:00
|
|
|
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
2024-05-12 02:42:05 +00:00
|
|
|
|
import org.springframework.cache.annotation.EnableCaching;
|
2025-02-22 08:44:38 +00:00
|
|
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
|
import org.springframework.core.env.Environment;
|
2024-06-13 10:44:15 +00:00
|
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
2023-12-13 03:44:35 +00:00
|
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 启动程序
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author xdadan
|
|
|
|
|
|
*/
|
|
|
|
|
|
@EnableScheduling
|
2024-05-12 02:42:05 +00:00
|
|
|
|
// 开启缓存
|
|
|
|
|
|
@EnableCaching
|
2024-06-13 10:44:15 +00:00
|
|
|
|
@EnableAsync
|
2024-12-31 08:00:59 +00:00
|
|
|
|
@ServletComponentScan("com.xdadan.erp.framework.security.filter")
|
2023-12-13 03:44:35 +00:00
|
|
|
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
|
|
|
|
|
public class LaunchApplication extends SpringBootServletInitializer {
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
|
initByLocal(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过本地配置文件运行
|
|
|
|
|
|
* @param args
|
|
|
|
|
|
*/
|
|
|
|
|
|
private static void initByLocal(String[] args){
|
|
|
|
|
|
String configFile = "";
|
|
|
|
|
|
try {
|
|
|
|
|
|
File directory = new File(".");
|
|
|
|
|
|
System.out.println(directory.getCanonicalPath());
|
|
|
|
|
|
System.out.println(directory.getAbsolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
configFile = PropertyUtil.getPropertyValue("config.properties", "config.file");
|
|
|
|
|
|
System.out.println("use config file:" + configFile);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
2025-02-22 08:44:38 +00:00
|
|
|
|
ConfigurableApplicationContext context =
|
|
|
|
|
|
new SpringApplicationBuilder(
|
2023-12-13 03:44:35 +00:00
|
|
|
|
LaunchApplication.class)
|
|
|
|
|
|
.properties("spring.config.location=" + configFile)
|
|
|
|
|
|
.web(WebApplicationType.SERVLET).run(args);
|
2025-02-22 08:44:38 +00:00
|
|
|
|
|
|
|
|
|
|
Environment env = context.getEnvironment();
|
|
|
|
|
|
String serverPort = env.getProperty("server.port");
|
|
|
|
|
|
String contextPath = env.getProperty("server.servlet.context-path", "");
|
|
|
|
|
|
System.out.println("\n\n==>系统启动成功!server.port=" + serverPort + " context-path=" + contextPath);
|
|
|
|
|
|
|
2023-12-13 03:44:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public void onStartup(ServletContext servletContext) throws ServletException {
|
|
|
|
|
|
// super.onStartup(servletContext);
|
|
|
|
|
|
// servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
|
|
|
|
|
|
// SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
|
|
|
|
|
|
// sessionCookieConfig.setHttpOnly(true);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Bean
|
|
|
|
|
|
// public DefaultWebSessionManager sessionManager() {
|
|
|
|
|
|
// DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
|
|
|
|
|
|
// defaultWebSessionManager.setGlobalSessionTimeout(60 * 30 * 1000);
|
|
|
|
|
|
// defaultWebSessionManager.setDeleteInvalidSessions(true);
|
|
|
|
|
|
// defaultWebSessionManager.setSessionValidationSchedulerEnabled(true);
|
|
|
|
|
|
// defaultWebSessionManager.setSessionIdCookieEnabled(true);
|
|
|
|
|
|
// // tomcat的JESSIONID自动生成模块
|
|
|
|
|
|
// defaultWebSessionManager.setSessionIdUrlRewritingEnabled(false);
|
|
|
|
|
|
// return defaultWebSessionManager;
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|