当您将 Grails 3 应用程序部署到独立的 tomcat 应用程序时,您不应使用 springbootserver.session.timeout
配置属性。它仅适用于嵌入式服务器。
要在部署到独立 tomcat 中的 SpringBoot 应用程序(Grails 3 应用程序构建在 SpringBoot 应用程序之上)中配置会话超时,您有两种选择:
A)部署在该 tomcat 实例中的每个应用程序的超时。
您可以直接在 tomcat 配置文件中编辑会话超时:
$TOMCAT_HOME/conf/web.xml
寻找块:
<!-- ==================== Default Session Configuration ================= -->
<!-- You can set the default session timeout (in minutes) for all newly -->
<!-- created sessions by modifying the value below. -->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
B)您可以在 Grails 3 应用程序中添加一个 web.xml 文件,每个应用程序都需要超时。
在路径 'src/main/webapp/WEB-INF/web.xml' 中创建一个文件,其内容为:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>