프로그래밍/Spring

[Spring] Spring Boot Live reload 설정 하기

@코린이 2023. 3. 17. 18:30

Spring Boot 로 Kotlin - thymeleaf 개발을 하면서 HTML을 수정할 때마다 reload 하는게 귀찮아서 프로젝트에 live reload 설정을 추가했다. (배포나갈 때는 설정하면 안됨!)

무슨 코드가 수정되든 reload 되는데 서버 수정하면 너무 오래 걸리기 때문에 HTML 코드 수정할때만 켜놓는것을 추천하다.

 

1. IntelliJ에서 Live reload 설정하기

1. Preferences 진입(단축키: cmd + ,)

2. Build Tools > Gradle > Build and run using 설정을 IntelliJ IDEA로 설정

Build Tools > Gradle > Build and run using 설정을 IntelliJ IDEA로 설정

3. Advanced Settings > Allow auto-make to start even if developed application is current running 체크 설정

Advanced Settings > Allow auto-make to start even if developed application is current running 체크 설정

4. Compiler > Build Project automatically 체크 설정

Compiler > Build Project automatically 체크 설정

2.  프로젝트 설정

1. build.gradle.kts 설정

dependencies에 devtools 추가

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

2. application.yaml 설정 파일에 추가

spring:
	devtools:
    	livereload:
        	enabled: true
        restart:
        	enabled: true

 

3. Chrome 확장프로그램 설치

1. 크롬 웹스토어로 이동

https://chrome.google.com/webstore/category/extensions?hl=ko 

 

Chrome 웹 스토어

Chrome에 사용할 유용한 앱, 게임, 확장 프로그램 및 테마를 찾아보세요.

chrome.google.com

 

2. Live Reload 검색하여 아무거나 골라 설치 > 필요할 때 활성화

 

끝!