Spring Boot Java Config 设置会话超时 [英] Spring Boot Java Config Set Session Timeout
问题描述
如何在 Spring Boot 应用程序中配置我的(嵌入式)Tomcat 会话超时?
How can I configure my (embedded) Tomcat Session Timeout in a Spring Boot Application?
public class SessionListener implements HttpSessionListener{
@Override
public void sessionCreated(HttpSessionEvent se) {
se.getSession().setMaxInactiveInterval(5*60);
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
}}
我有一个 SessionListener,但我不知道我必须在哪个类中将此侦听器添加到上下文中.
I have a SessionListener but I have no idea in which class I have to add this Listener to the Context.
推荐答案
您应该能够在 application.properties 文件中设置 server.session.timeout
.
You should be able to set the server.session.timeout
in your application.properties file.
ref: http://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html
此属性在更高版本的 Spring Boot 中已更改为 server.servlet.session.timeout
.
This property has changed in later versions of Spring Boot to server.servlet.session.timeout
.
这篇关于Spring Boot Java Config 设置会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!