[TIL] 스프링부트 자동 재시작

서버 개발을 하면서 코드 변경이 있을 때마다 서버를 멈추고 다시 빌드를 해줘야 한다면 너무 불편하다. 코드 저장시 자동으로 서버가 재시동되도록 설정하는 방법을 찾아봤다.

먼저 build.gradle에 dependency를 추가해준다.

dependencies {
  developmentOnly("org.springframework.boot:spring-boot-devtools")
}

다음으로 재설치해준다.

gradle 재설치가 끝났다면, intellij 설정을 해줘야 한다.

상단의 Intellij IDEA > Settings > Build, Execution, Deployment > Compiler로 이동한다.

Build project automatically 체크해준다.

다음으로 Advanced Settings에 들어가 Allow auto-make to start even if developed application is currently running 도 체크해준다.

이제 서버를 재시작하면 코드가 변경될 때 자동으로 재시작된다.