Spring Downloading Java Configuration Configuring Session Timeout

How to configure my (built-in) 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) { }} 

I have a SessionListener, but I have no idea in which class I should add this listener to the context.

+25
source share
5 answers

You must set server.session.timeout in the application.properties file.

ref: http://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

+28
source

server.session.timeout in application.properties has been deprecated. Correct setting:

 server.servlet.session.timeout=60s 

Also note that Tomcat will not let you set the wait time to less than 60 seconds. See https://github.com/spring-projects/spring-boot/issues/7383 for more on this minimum value.

+40
source
  • Spring Boot version 1.0: server.session.timeout=1200
  • Spring Boot version 2.0: server.servlet.session.timeout=10m
    NOTE. If no duration suffix is ​​specified, seconds will be used.
+17
source

server.session.timeout = 60 (in minutes, i.e. 60 minutes)

0
source

I think it is a good idea to install 1S for Springboot

-5
source

Source: https://habr.com/ru/post/1260818/


All Articles