79 lines
2.8 KiB
Java
79 lines
2.8 KiB
Java
|
|
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;
|
||
|
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||
|
|
import org.springframework.cache.annotation.EnableCaching;
|
||
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||
|
|
|
||
|
|
import java.io.File;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 启动程序
|
||
|
|
*
|
||
|
|
* @author xdadan
|
||
|
|
*/
|
||
|
|
@EnableScheduling
|
||
|
|
// 开启缓存
|
||
|
|
@EnableCaching
|
||
|
|
@EnableAsync
|
||
|
|
@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) {
|
||
|
|
// TODO Auto-generated catch block
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
|
||
|
|
new SpringApplicationBuilder(
|
||
|
|
LaunchApplication.class)
|
||
|
|
.properties("spring.config.location=" + configFile)
|
||
|
|
.web(WebApplicationType.SERVLET).run(args);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// @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;
|
||
|
|
// }
|
||
|
|
}
|