[Spring Boot] HTML, JS, CSS 등 정적 리소스를 바로 적용시키는 방법

Sol Kim·2022년 10월 11일
0

SpringBoot

목록 보기
2/2
post-thumbnail

IntelliJ의 수정 사항을 웹에 바로 반영하도록 설정하는 방법!

1. build.gradle

build.gradle에 의존성을 추가합니다.

developmentOnly 'org.springframework.boot:spring-boot-devtools'

compile('org.springframework.boot:spring-boot-devtools')

둘 중 하나 추가하고 build 해주세요!


2. application.yml (properties)

▲ yml에서 적는 방식입니다

▼ properties는 이렇게 적어주세요!

spring.devtools.livereload.enabled=true
spring.devtools.restart.enabled=false
spring.thymeleaf.cache=false


3. Run/Debug Configurations

1) Run 탭 > Edit Configurations... 클릭
2) Spring Boot > 사용하는 Application 선택
3) Build and Run 구역 오른쪽 Modify options 클릭 ▼

4) On 'Update' action, On frame deactivation - Update classes and resources 로 변경 클릭!

5) 하단에 반영 확인한 후, OK 버튼 클릭!

보통 여기서 해결이 완료되긴 하지만,
혹시 그래도 반영이 안되는 경우에는 4번째 방법까지 해주기! ▼


4. IntelliJ Auto Compile 활성화

  • IntelliJ 2021.2 버전부터 Registry...가 아닌 Advanced Settings에서 설정하도록 바뀌었다.
  • 사실 이거 활성화시켜놓으면 자꾸 혼자 build 진행시켜버려서 불편하긴 하지만.. ㅠ

  📌 IntelliJ 2021.2 이전 버전

      1) Action 검색창(ctrl+shift+a) > registry 검색

      2) compiler.automake.allow.when.app.running 항목 체크하기
          이 항목이 아무리 찾아도 안 보이면 2021.2 이후 버전 방법으로 ㄱㄱ!▼

  📌 IntelliJ 2021.2 이후 버전

      1) Setting(ctrl+alt+s) > Build, Execution, Deployment > Compiler
          > Build Project Automatically 체크

      2) Setting(ctrl+alt+s) > Advanced Settings
          > Allow auto-make to start even if ~ 체크





참고 :
https://yjh5369.tistory.com/entry/intellij에서-static-resourcehtml-js-등-바로-반영되게-하는-방법-for-spring-boot
https://velog.io/@jodawooooon/IntelliJ-자동-빌드-설정-방법-Registry에-compiler.automake.allow.when.app.running이-없는-경우

profile
Junior Developer

0개의 댓글