Application property “server.servlet.session.timeout” is not working in Spring Boot project

后端 未结 6 1830
南方客
南方客 2020-12-11 15:55

According to the documentation of Spring Boot, session timeout can be configured by setting

server.servlet.session.timeout= 300s

in

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 16:35

    A possible cause for this problem might be using @EnableRedisHttpSession. As explained in this answer:

    By using @EnableRedisHttpSession you are telling Spring Boot that you want to take complete control over the configuration of Redis-based HTTP sessions. As a result, its auto-configuration backs off and server.servlet.session.timeout has no effect. If you want to use server.servlet.session.timeout then you should remove @EnableRedisHttpSession. Alternatively, if you want to use @EnableRedisHttpSession then you should use the maxInactiveIntervalInSeconds attribute to configure the session timeout.

    Hope this helps someone.

提交回复
热议问题