반응형
Spring Boot 1.x과 Spring Boot 2.x 이상에서의 세션 만료 시간 설정 방법이 약간 차이가 있다.
◆ Spring Boot 1.x 의 세션 만료 시간 설정
application.properties 또는 application.yml 에서 설정할 수 있으며, 숫자(초)로만 설정가능하다.
명시적으로 세션 만료 시간을 설정하지 않는 경우 디폴트 30분으로 설정된다.
아래는 1시간으로 세션 만료 시간을 설정하는 예시이다.
1. application.properties
server.session.timeout=3600 # 1시간 (3600초)
2. application.yml
server:
session:
timeout: 3600 # 1시간 (3600초)
◆ Spring Boot 2.x 이상 버전의 세션 만료 시간 설정
마찬가지로 application.properties 또는 application.yml 에서 설정할 수 있으며, 명시적으로 세션 만료 시간을 설정하지 않는 경우 디폴트 30분으로 설정된다.
다만 Spring Boot 1.x 에서 숫자(초)로만 시간을 설정하는 것과 다르게 Spring Boot 2.x 이상의 버전에서는 단위(h, m, s)를 포함시키거나 ISO-8601 형식으로 시간을 설정할 수 있다.
숫자로만 지정한 경우는 초단위로 인식한다.
아래는 1시간으로 세션 만료 시간을 설정하는 예시이다.
1. application.properties
# 1시간
server.servlet.session.timeout=3600 # 1시간 (3600초)
server.servlet.session.timeout=3600s # 1시간 (3600초 : 단위)
server.servlet.session.timeout=60m # 1시간 (60분 : 단위)
server.servlet.session.timeout=1h # 1시간 (1시간 : 단위)
server.servlet.session.timeout=PT3600S # 1시간 (3600초 : ISO-8601 형식)
server.servlet.session.timeout=PT60M # 1시간 (60분 : ISO-8601 형식 )
server.servlet.session.timeout=PT1H # 1시간 (1시간 : ISO-8601 형식 )
2. application.yml
server:
servlet:
session:
timeout: 3600 # 1시간 (3600초)
timeout: 3600s # 1시간 (3600초 : 단위)
timeout: 60m # 1시간 (60분 : 단위)
timeout: 1h # 1시간 (1시간 : 단위)
timeout: PT3600S # 1시간 (3600초 : ISO-8601 형식)
timeout: PT60M # 1시간 (60분 : ISO-8601 형식)
timeout: PT1H # 1시간 (1시간 : ISO-8601 형식)
참조
server.session.timeout
https://docs.spring.io/spring-boot/docs/1.5.9.RELEASE/reference/htmlsingle/#boot-features-customizing-embedded-containers
server.servlet.session.timeout
https://docs.spring.io/spring-boot/docs/2.4.x/reference/html/appendix-application-properties.html#server.servlet.session.timeout
글 내용 중 잘못된 부분이 있거나, 첨부하실 내용이 있으시면 댓글로 남겨주세요. 공부하는데 많은 도움이 됩니다.
-- 기억의 유효기간은 생각보다 짧다. --
반응형
'▹ JAVA 기반 프레임워크 > 스프링부트 (Spring Boot)' 카테고리의 다른 글
[Spring] MultipartFile 파일 업로드 최대크기 제한 조정 (0) | 2024.10.02 |
---|---|
[Spring] MultipartFile 비어있는 파일 확인 - isEmpty() (0) | 2024.07.31 |
패키징 된 war나 jar파일내의 File 읽어오기 (2) | 2024.07.23 |
스프링 부트(Spring Boot)에서 JSP 사용하기 (1) | 2023.12.27 |
[Spring] ClassPathResource 경로 (0) | 2023.09.15 |