Newsletter

Spring Boot – How to Reload Changes Without Restarting the Server

One of the main challenge for the java developers is to deploy the apps and restart server when ever there is a code change. In this article, I am going to show you how to reload the code changes without having to restart the server. In Spring Boot this can be achieved by adding a DevTools module, just add the following dependency in your Spring Boots pom.xml and build it. 

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

Spring Boot DevTools module does exactly what developers needed, this eliminates the process of manually deploying the changes. DevTools will auto restart the server when we have changes. Spring team they haven’t included this feature in Spring Boot’s initial version, upon several request they added this feature later.

Final pom.xml looks like

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.java4s</groupId>
  <artifactId>SpringBootDevTools</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  	<parent>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-parent</artifactId>
	    <version>1.5.6.RELEASE</version>
	</parent>
	
	<dependencies>
	    <dependency>
	        <groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-starter-web</artifactId>
	    </dependency>
	    <dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-devtools</artifactId>
		<optional>true</optional>
	     </dependency>
	</dependencies>
	
	<properties>
	 <java.version>1.8</java.version>
	</properties> 
  
</project>

You can start the server and run the application. Now if you do some code changes to your project files, you no need to restart the server again to view the changes rather just refresh your browser 😉 that’s it.

Hope your enjoy this article, you can download the complete example by clicking on download button.

​​

You Might Also Like

  ::. About the Author .::

Java4s_Author
- Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

4 Responses to “Spring Boot – How to Reload Changes Without Restarting the Server”
  1. sundip says:

    super mama . chala help avtondi.

  2. Swapna says:

    But it didn't reflected in my application even I refreshed the browser.

  3. jagan says:

    Hi Siva,

    I have read the Spring Boot Article its was very Nice

    But I have a small doubt,spring BOOT provided inbuilt server like tomcat, GlassFish etc
    so,spring boot application move to production server there we are using different application server ,like WebLogic some diff, any changes in need do to in spring Boot or not?

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.