Skip to content

Commit 46a029d

Browse files
committed
bugfix
1 parent 79d46a1 commit 46a029d

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

publiccms-parent/publiccms/src/main/java/boot/SpringBootApplication.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66
import org.apache.catalina.valves.RemoteIpValve;
77
import 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;
1211
import org.springframework.boot.web.servlet.ServletContextInitializer;
13-
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
14-
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
1512
import org.springframework.context.annotation.Bean;
1613
import org.springframework.context.annotation.Configuration;
1714
import org.springframework.context.annotation.Import;
@@ -37,10 +34,16 @@
3734
public 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

publiccms-parent/publiccms/src/main/java/config/spring/ApplicationConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.springframework.core.env.Environment;
2626
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
2727
import org.springframework.core.io.support.PropertiesLoaderUtils;
28-
import org.springframework.orm.hibernate5.HibernateTransactionManager;
29-
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
28+
import org.springframework.orm.jpa.hibernate.HibernateTransactionManager;
29+
import org.springframework.orm.jpa.hibernate.LocalSessionFactoryBean;
3030
import org.springframework.scheduling.annotation.EnableScheduling;
3131
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
3232
import org.springframework.stereotype.Controller;

0 commit comments

Comments
 (0)