Search code examples
javaspring-bootspring-securityspring-session

What is the priority between server.servlet.session.timeout and jdbcSessionRepository.setDefaultMaxInactiveInterval


In my spring boot project, I find two ways to set the session timeout, the first is set the server.servlet.session.timeout in application.properties, and the another way is using jdbcSessionRepository.setDefaultMaxInactiveInterval in my java program. I find the min of them can work when real use, so my question is: What is the priority between them, or what is the difference of them. Thank for your answers.

server.servlet.session.timeout and setDefaultMaxInactiveInterval


Solution

  • The difference is that setDefaultMaxInactiveInterval is part of the Spring Session project, so it can only be used if you include Spring Session in your project.

    server.servlet.session.timeout can be used in a servlet based application, regardless of whether you include Spring Session.

    If you set both, the value in setDefaultMaxInactiveInterval takes precedence.