spring boot設置session超時時間

按優先級高到低說:web

第一種:spring

spring boot 啓動類裏面:mybatis

 1 package com.mycenter;
 2 
 3 import org.mybatis.spring.annotation.MapperScan;
 4 import org.springframework.boot.SpringApplication;
 5 import org.springframework.boot.autoconfigure.SpringBootApplication;
 6 import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
 7 import org.springframework.boot.web.servlet.ServletComponentScan;
 8 import org.springframework.context.annotation.Bean;
 9 
10 @SpringBootApplication
11 @MapperScan(value = "com.mycenter.mapper")
12 @ServletComponentScan
13 public class MycenterApplication {
14 
15     public static void main(String[] args) {
16         SpringApplication.run(MycenterApplication.class, args);
17     }
18 
19 
20     @Bean
21     public EmbeddedServletContainerCustomizer containerCustomizer(){
22         return container -> {
23             container.setSessionTimeout(7200);/*單位爲S*/
24         };
25     }
26 }

第二種:app

暫時用這兩種。spa

相關文章
相關標籤/搜索