DevTools là optional dependency tăng tốc developer experience — tự động restart và reload khi có thay đổi.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>Tính năng chính:
- Automatic restart — detect file thay đổi trên classpath → restart context ~1-2s (nhanh nhờ 2 ClassLoader).
- LiveReload — browser tự refresh sau restart.
- Property defaults — tắt cache template (Thymeleaf), bật debug logging.
2 ClassLoader trick: classloader riêng cho libs (ít đổi) vs app code (hay đổi) → chỉ reload app classloader → nhanh hơn nhiều.
Tự động disable khi: chạy java -jar (fully packaged), production environment phát hiện qua flag.
Không dùng trong production — làm chậm, không an toàn.
DevTools is an optional dependency that speeds up the developer experience — auto-restarts and reloads on changes.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>Key features:
- Automatic restart — detects classpath file changes → restarts context in ~1-2s (faster thanks to two ClassLoaders).
- LiveReload — browser auto-refreshes after restart.
- Property defaults — disables template caching (Thymeleaf), enables debug logging.
Two ClassLoader trick: separate classloaders for libs (rarely change) vs app code (changes often) → only the app classloader reloads.
Auto-disabled when: running as java -jar (fully packaged) or a production environment is detected.
Do not use in production — adds overhead, unsafe to expose.