Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Efficient Hot Deployment for Spring Boot Development

Tech May 17 1

Hot deployment eliminates the need for full application restarts when modifying source files by dynamically reloading only the updated compiled classes or templates, boosting development efficiency.

Maven Spring Loaded Plugin

Add the Spring Loaded dependency to the spring-boot-maven-plugin section of your pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>springloaded</artifactId>
                    <version>1.2.5.RELEASE</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Launch the application using mvn spring-boot:run. After modifying a controller or HTML file, press Ctrl+Shift+F9 in IntelliJ IDEA to reload the updated class and refresh the browser to see changes.

Note: This method works only with mvn spring-boot:run, not by diretcly running Application.java.

Required IDE and Configuration Checks

  1. Ensure IntelliJ IDEA has automatic compilation enabled: Go to Preferences > Compiler and check Build project automatically.
  2. If using Thymeleaf, disable template caching in application.properties to reflect HTML changes:
# Disable Thymeleaf cache for development (set to true in production)
spring.thymeleaf.cache=false

Spring Boot DevTools Depednency

Add the DevTools hot deployment module to pom.xml:

<!-- Hot deployment module -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional> <!-- Required for hot deployment to work -->
</dependency>

Restart the application (either via mvn spring-boot:run or directly running Application.java). Any changes to controllers or HTML files will now be reflected immediately upon browser refresh.

Tags: Spring Boot

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.