개발 지식/Memo

spring-boot-devtools 라이브러리

통사부 2022. 6. 9. 15:39
728x90

spring-boot-devtools 라이브러리를 사용하면 캐시 삭제 등 개발 시 유용한 기능들을 제공한다

 

가장 대표적인 예로 thymeleaf 등 개발 시 동적 값을 변경할 경우 서버를 재시작해야하는데

devtools 를 사용하면 리컴파일로 간단하게 처리할 수 있다

 

gradle 기준으로 작성
dependencies {
   ....
   implementation 'org.springframework.boot:spring-boot-devtools'
   ....
}

 

라이브러리 추가 후 th:text 부분의 문구를 변경했을 경우
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Hello</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'변경 후 '" >기본 문구</p>
</body>
</html>

다시 컴파일 후 새로고침을 하면 바로 적용되는 것을 확인할 수 있다!

728x90