springboot + shiro 设置session过期时间

在springboot + shiro中,可以设置session过期时间。有两种方式:

  1. 在application.yml 中设置过期时间,但是在使用外部tomcat的时候不起作用
    server:
      connection-timeout:
      servlet:
        session:
          timeout:

    在这里,设置了两座过期时间,您试一下,可能我这里是哪里不对。

  2. 因为使用shiro,那么就在shiro的sessionManager中设置过期时间

    @Bean
        public DefaultWebSessionManager getWebSessionManager(){
            DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
            defaultWebSessionManager.setGlobalSessionTimeout(10000L);
            return defaultWebSessionManager;
        }

    这里有个问题,我见过期时间设置的是30m,所以,我就用了一个60s来替换,不行。改为了10000L这样表示,失效时间为10秒。就可以了

发布了145 篇原创文章 · 获赞 6 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/m0_37626203/article/details/103617887