1.
요즘 개발하면서 hot swap 기능은 필수다. intellij 로 spring boot 하면서 기능이 있나 찾아보니 역시 있다. 많은 가이드가 있지만 시간이 지나서 적용 안 되는 것도 있고 이것저것 해 봐도 잘 안 된다.
아래의 설정들 다 적용 후 소스를 수정하고 실제 hot swap 이 동작해서 반영되는데 시간이 다소 걸린다. 설정 중 어떤게 필수인지는 잘 모르겠고, 중요한 건 반영되는데 시간이 걸린다는 것. 약 3~4초 정도.
2024 기준으로 community 버전도 hot swap이 잘 된다.
2.
//build.gradle
dependencies {
...
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
//application.properties
spring.devtools.livereload.enabled=true
spring.devtools.remote.restart.enabled=false
spring.freemarker.cache = false
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
3.
Settings > Build, Execution, Deployment > Debugger > HotSwap
- Enable ‘JVM will hang’ warning 체크
- Reload classes after compilation: always 체크
4.
Settings > Build, Execution, Deployment > Compiler
- Build project automatically 체크
5.
Settings > Build, Execution, Deployment > Advanced Settings
- Allow auto-make to start even if developed application is currently running 체크