DevTools

Hot reload and browser auto-refresh for faster development.

Configuration

# application.yaml
jweb:
  dev:
    # Enable hot reload
    hot-reload: true
    # Paths to watch for changes
    watch-paths: src/main/java,src/main/resources
    # Debounce delay in ms (lower = faster reload, min 10)
    debounce-ms: 50

Add to Layout

Include the DevServer script in your layout for auto-refresh:

import com.osmig.Jweb.framework.dev.DevServer;

public Element render() {
    return html(
        head(...),
        body(
            content,
            DevServer.script()  // Enables hot reload
        )
    );
}

Spring DevTools

Add Spring DevTools for automatic app restart on changes:

<!-- pom.xml -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

How It Works

  • DevServer watches your source files for changes
  • Spring DevTools automatically restarts the app
  • Browser auto-refreshes via SSE (Server-Sent Events)
  • Debounce batches rapid changes to avoid multiple reloads

IDE Setup

For seamless hot reload, configure your IDE:

  • IntelliJ: Enable 'Build project automatically' in Settings > Build
  • IntelliJ: Enable 'Allow auto-make' in Registry (Ctrl+Shift+A)
  • VS Code: Use the Java Extension Pack with auto-build
Lower debounce-ms for faster reloads, but may cause multiple reloads on save.