trace/src/main/java/com/l/tracecd/config/SessionConfig.java
Lee c5dee7e444
Some checks failed
Java Maven 3.9.9 & JDK 26 CI/CD Pipeline / build-and-deploy (push) Failing after 9m3s
初始化项目
2026-06-08 15:04:18 +08:00

29 lines
968 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.l.tracecd.config;
import com.l.tracecd.constant.Constants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.MapSession;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
import java.time.Duration;
import java.util.concurrent.ConcurrentHashMap;
/**
* Spring Session 配置
* 基于内存的 Session 存储30天有效期
*/
@Configuration
@EnableSpringHttpSession
public class SessionConfig {
@Bean
public SessionRepository<MapSession> sessionRepository() {
MapSessionRepository repository = new MapSessionRepository(new ConcurrentHashMap<>());
repository.setDefaultMaxInactiveInterval(Duration.ofSeconds(Constants.SESSION_TIMEOUT_SECONDS));
return repository;
}
}