Spring Boot Java Config 设置会话超时 [英] Spring Boot Java Config Set Session Timeout

查看:50
本文介绍了Spring Boot Java Config 设置会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 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.

ref: https://docs.spring.io/spring-boot/docs/2.4.x/reference/html/appendix-application-properties.html#server.servlet.session.timeout

这篇关于Spring Boot Java Config 设置会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆