55
66import org .apache .catalina .valves .RemoteIpValve ;
77import org .springframework .boot .SpringApplication ;
8- import org .springframework .boot .web .embedded .jetty .JettyServletWebServerFactory ;
9- import org .springframework .boot .web .embedded .tomcat .TomcatServletWebServerFactory ;
10- import org .springframework .boot .web .embedded .undertow .UndertowServletWebServerFactory ;
11- import org .springframework .boot .web .server .ErrorPage ;
8+ import org .springframework .boot .tomcat .servlet .TomcatServletWebServerFactory ;
9+ import org .springframework .boot .web .error .ErrorPage ;
10+ import org .springframework .boot .web .server .servlet .ServletWebServerFactory ;
1211import org .springframework .boot .web .servlet .ServletContextInitializer ;
13- import org .springframework .boot .web .servlet .server .AbstractServletWebServerFactory ;
14- import org .springframework .boot .web .servlet .server .ServletWebServerFactory ;
1512import org .springframework .context .annotation .Bean ;
1613import org .springframework .context .annotation .Configuration ;
1714import org .springframework .context .annotation .Import ;
3734public class SpringBootApplication {
3835
3936 /**
40- * <p>在idea中通过main方法启动需要将工作目录改为 publiccms 模块所在的路径,否则静态资源不能加载
41- * <p>ideaのmainメソッドから始めるには、作業ディレクトリをpubliccmsモジュールが配置されているパスに変更する必要があり、そうしないと静的リソースをロードできません
42- * <p>To start through the main method in idea, you need to change the working directory to the path where the publiccms module is located, otherwise the static resources cannot be loaded
43- * <p>https://www.publiccms.com/question/2018/02-13/376.html
37+ * <p>
38+ * 在idea中通过main方法启动需要将工作目录改为 publiccms 模块所在的路径,否则静态资源不能加载
39+ * <p>
40+ * ideaのmainメソッドから始めるには、作業ディレクトリをpubliccmsモジュールが配置されているパスに変更する必要があり、そうしないと静的リソースをロードできません
41+ * <p>
42+ * To start through the main method in idea, you need to change the working
43+ * directory to the path where the publiccms module is located, otherwise
44+ * the static resources cannot be loaded
45+ * <p>
46+ * https://www.publiccms.com/question/2018/02-13/376.html
4447 *
4548 * @param args
4649 */
@@ -53,19 +56,10 @@ public static void main(String[] args) {
5356 */
5457 @ Bean
5558 public ServletWebServerFactory servletContainer () {
56- String server = System .getProperty ("cms.server" );
57- AbstractServletWebServerFactory factory = null ;
58- if ("jetty" .equalsIgnoreCase (server )) {
59- factory = new JettyServletWebServerFactory ();
60- } else if ("undertow" .equalsIgnoreCase (server )) {
61- factory = new UndertowServletWebServerFactory ();
62- } else {
63- TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory ();
64- String initProto = System .getProperty ("cms.initProto" );
65- if (CommonUtils .notEmpty (initProto ) && "false" .equalsIgnoreCase (initProto )) {
66- tomcat .addEngineValves (new RemoteIpValve ());
67- }
68- factory = tomcat ;
59+ TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory ();
60+ String initProto = System .getProperty ("cms.initProto" );
61+ if (CommonUtils .notEmpty (initProto ) && "false" .equalsIgnoreCase (initProto )) {
62+ factory .addEngineValves (new RemoteIpValve ());
6963 }
7064 Set <ErrorPage > errorPageSet = factory .getErrorPages ();
7165 errorPageSet .add (new ErrorPage (Throwable .class , "/error/500.html" ));
@@ -77,8 +71,8 @@ public ServletWebServerFactory servletContainer() {
7771 factory .setContextPath (System .getProperty ("cms.contextPath" , "" ));
7872 factory .setDisplayName ("PublicCMS" );
7973 factory .setRegisterDefaultServlet (true );
80- factory .getSession ().setTimeout (Duration .ofMinutes (20 ));
81- factory .getJsp ().setRegistered (false );
74+ factory .getSettings (). getSession ().setTimeout (Duration .ofMinutes (20 ));
75+ factory .getSettings (). getJsp ().setRegistered (false );
8276 return factory ;
8377 }
8478
0 commit comments