-
[SPRING BOOT] jar가 아닌 war로 배포 및 구동을 원할 경우스터디 노트 2024. 2. 23. 10:57
소스코드를 보다보니 Spring Boot 프로젝트임에도 불구하고 희한한 코드를 볼 수 있었습니다.
@SpringBootApplication public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
여기서 눈길을 끈 부분은 SpringBootServletInitializer와 SpringApplicationBuilder를 사용하는 configure 메소드였습니다.
굳이 왜 저걸 선언을 했을까?
찾아보니 Spring Boot 프로젝트에서 사용하는 임베디드 톰캣은 기본적으로 jar로 구동이 됩니다.
하지만 특정 사유(?)에 의하여 war로 배포를 하고 서버를 구동시켜야 할 경우 위와 같은 방법으로 진행해주시면 됩니다.
<packaging>war</packaging>
해당 사유로 인하여 configure 메소드를 새롭게 override하여 정의해 사용했다는 것을 알 수 있었습니다.
'스터디 노트' 카테고리의 다른 글
Nginx 설치 및 Reverse Proxy 설정 (0) 2024.05.14 Host <-> Docker 간 파일 전송 명령어 (docker cp) (0) 2024.05.14 Redis로 초간단 Pub / Sub 구축하기! Redis + Spring Boot (1) 2023.12.29 [Google Bard] 구글 바드 Spring Boot 연동하기! (feat. 제미나이 AI가 똑똑해졌다며?) (1) 2023.12.28 레디스(Redis)? 함 써봅시다. Spring Boot + Redis 연동하기! (1) 2023.12.21