Hot Swapping in Spring Boot with Eclipse STS
In web application developing, hot swapping means that you can modify the source code and see the changes immediately, simply by reloading the page in the web browser, without rebuilding your project and have to restart the web server.
Some java web frameworks are ready with it, Play Framework is a good example, whereas using Spring Boot you have to do a little work.
1. Get spring-loaded to handle the java code
You can download spring-loaded 1.2.0 from here:
or check here for the last version:
2. Add spring-loaded in Eclipse STS
Open Eclipse→ Right click on your project (your Spring Boot web app) → Run As →Spring Boot (launch the application at least one time as Spring Boot application).
Right click on your project→ Run As → Run Configurations… → Java Application → <project_name> → Arguments
Inside the text box VM Arguments append the spring-loaded option:
<path-to> is the directory path where you have the spring-loaded jar file.
Then click Apply → Run.
Now you can try to modify some java code and see the changes reloading the web page.
3. Configure Thymeleaf
application.properties file and add the following line:
This option disables the cache for thymeleaf, allowing you to modify thymeleaf pages and just reloading the page in the web browser to see the changes.