zoukankan      html  css  js  c++  java
  • Springboot设置session超时时间

    按优先级高到低说:

    第一种:

    spring boot 启动类里面:

    package com.mycenter;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
    import org.springframework.boot.web.servlet.ServletComponentScan;
    import org.springframework.context.annotation.Bean;
    
    @SpringBootApplication
    @MapperScan(value = "com.mycenter.mapper")
    @ServletComponentScan
    public class MycenterApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(MycenterApplication.class, args);
        }
    
        @Bean
        public EmbeddedServletContainerCustomizer containerCustomizer(){
            return container -> {
                container.setSessionTimeout(7200);/*单位为S*/
            };
        }
    }
    

    第二种 yml文件配置

    server:
        port: 8080
        session:
            timeout: 7200
    缘于生活,而归于工作。本人所书,而意于分享。 如有转载,请注明出处! --活出自己范儿
  • 相关阅读:
    用户使用情况报告
    项目验收与总结
    Beta阶段冲刺-6
    Beta阶段冲刺-5
    Beta阶段冲刺-4
    Beta阶段冲刺-3
    Beta阶段冲刺-2
    Beta阶段冲刺-1
    『编程题全队』Beata阶段项目复审
    『编程题全队』Beta 阶段用户使用调查报告
  • 原文地址:https://www.cnblogs.com/Small-sunshine/p/11648612.html
Copyright © 2011-2022 走看看