Skip to main content

Spring Boot

Open in ChatGPT

In a Spring Boot app, the webforJ build plugin delivers the development tools to development runs. The project declares no dependency for them, and they're never part of the packaged app.

Requirements

The starter dependency and the build plugin. A project created from an archetype has both.

pom.xml
<dependency>
<groupId>com.webforj</groupId>
<artifactId>webforj-spring-boot-starter</artifactId>
</dependency>
pom.xml
<plugin>
<groupId>com.webforj</groupId>
<artifactId>webforj-maven-plugin</artifactId>
<version>${webforj.version}</version>
<extensions>true</extensions>
</plugin>

Turning live reload on

application.properties
webforj.devtools.livereload.enabled=true
server.shutdown=immediate

Start the app as usual, mvn with Maven or ./gradlew bootRun with Gradle. Java changes apply after a compile, stylesheet and image changes apply in place, and sources under src/main/frontend rebuild through the frontend watch. The remaining keys are listed in the settings.

Spring DevTools

Spring DevTools is optional, live reload works without it. To use its restart model, add its dependency:

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

With Spring DevTools present, a compiled change restarts the Spring context and the browser refreshes when the restart completes. With a hotswap tool configured as well, the tool applies the class updates and the restart stays off.

Production builds

mvn package and ./gradlew bootJar produce an app without development tools, with no exclusion, profile, or property required. The webforj.devtools.livereload.enabled property has no effect in a packaged app.