Springboot app session timeout

后端 未结 5 1308
北荒
北荒 2021-01-04 11:12

I have created a SpringBoot MVC/Security app 1.2.2.RELEASE and my application.properties contains server settings like

#Tomcat port and contextPath details
s         


        
5条回答
  •  滥情空心
    2021-01-04 11:41

    (This applies to Spring 1.5.x at the time of this writing)

    Note that if you're using Redis session @EnableRedisHttpSession (such as in the other comment @Phoebe Li's case), then the application property server.session won't be applied. You'll have to set it manually by code like this:

    @EnableRedisHttpSession
    public class HttpSessionConfig {
        @Bean
        public RedisOperationsSessionRepository sessionRepository(RedisConnectionFactory factory) {
            RedisOperationsSessionRepository sessionRepository = new RedisOperationsSessionRepository(factory);
    
            //Set the TTL of redis' key, which in turn will expire session when TTL is reached
            sessionRepository.setDefaultMaxInactiveInterval(15); //e.g. 15 seconds
    
            return sessionRepository;
        }I
    }
    

提交回复
热议问题