spring boot设置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*/ }; } }
第二种:
暂时用这两种。