EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Spring Tutorial Spring Boot DevTools
Secondary Sidebar
Spring Tutorial
  • Spring Boot
    • What is Spring Boot
    • Spring Boot flyway
    • Spring Boot framework
    • Spring Boot Logback
    • Spring Boot actuator endpoints
    • Spring Boot gRPC
    • Spring Boot jdbctemplate example
    • Spring Boot ehcache
    • Spring Boot Architecture
    • Spring Boot Port
    • Introduction of spring boot
    • Spring Boot ide
    • Spring Boot Netty
    • Spring Boot ORM
    • Spring Boot Versions
    • Spring Boot JUnit
    • Spring Boot Keycloak
    • Spring Boot gradle
    • Spring Boot Lombok
    • Spring Boot autowired
    • Spring Boot bean
    • Spring Boot hibernate
    • Spring Boot integration test
    • Spring Boot jdbc
    • Spring Boot MongoDB
    • Spring Boot postgresql
    • Spring Boot rest
    • Spring Boot swagger
    • Spring Boot thymeleaf
    • Spring Boot Unit Test
    • Spring Boot Webflux
    • Spring Boot webclient
    • Spring Boot kubernetes
    • Spring Boot Properties
    • Spring Boot Validation
    • Spring Boot Feature
    • Spring Boot Application
    • Spring Boot email
    • Spring Boot MVC
    • Spring Boot Exception Handling
    • Spring Boot Starter Parent
    • Spring Boot Docker
    • Spring Boot Logging
    • Spring Boot Query
    • Spring Boot Multiple Data Sources
    • Spring Boot Basic Authentication
    • Spring Boot Test
    • Spring Boot jwt
    • Spring Boot Liquibase
    • Spring Boot Prometheus
    • Spring Boot debug
    • Spring Boot GraalVM
    • Spring Boot Batch
    • Spring Boot controller
    • Spring Boot CLI
    • Spring Boot file upload
    • Spring Boot interceptor
    • Spring Boot Service
    • Spring Boot Configuration
    • Spring Boot Datasource Configuration
    • Spring Boot Annotations
    • Spring Boot Starter We
    • Spring Boot Actuator
    • Spring Boot DevTools
    • Spring Boot Repository
    • Spring Boot Dependencies
    • Spring Boot Path Variable
    • Spring Boot Microservices
    • Spring Boot Run Command
    • Spring Boot application.properties
    • Spring Boot Transaction Management
    • Spring Boot Banner
    • Spring Boot JPA
    • Spring Boot Change Port
    • Spring Boot RestTemplate
    • Spring Boot cors
    • Spring Boot HTTPS
    • Spring Boot OAuth2
    • Spring Boot Profiles
    • Spring Boot Interview Questions
    • Spring Boot filter
    • Spring boot logging level
    • Spring Boot Cache
    • Spring Boot Advantages
    • Spring Boot Scheduler
    • Spring Boot Initializr
    • Spring Boot Maven
    • Spring Boot Admin
    • Spring Boot Tomcat
    • Spring Boot WebSocket
    • Spring Boot Executable Jar
    • Spring Boot CommandLineRunner
    • Spring Boot DataSource
    • Spring Batch Scheduler
    • Spring Batch Example
    • Spring Batch Tasklet
    • Spring Batch Admin
    • Spring Batch
    • Spring Boot Qualifier
    • Spring Boot War
    • Spring Boot Test Configuration
  • Spring
    • What is Spring Framework?
    • Spring Architecture
    • What is Spring Integration?
    • IoC Containers
    • What is AOP?
    • Spring Modules
    • Spring Batch Processing
    • Spring Batch Partitioner
    • Spring Batch Job
    • Spring AOP
    • Spring Expression Language
    • Dependency Injection in Spring
    • Spring Batch Architecture
    • Spring framework Interview Questions
  • Spring Cloud Basics
    • What is Spring Cloud
    • Spring Cloud Contract
    • Spring Cloud Components
    • Spring Cloud Version
    • Spring Cloud Data Flow
    • Spring cloud stream
    • Spring Cloud Dependencies
    • Spring cloud microservices
    • spring cloud gateway
    • Spring Cloud Config
    • Spring Cloud Kubernetes
    • Spring Cloud Sleuth

Related Courses

Spring Boot Certification Course

Spring Framework Course Training

All in One Data Science Course

Spring Boot DevTools

By Shalu SharmaShalu Sharma

Spring Boot DevTools

Definition of Spring Boot DevTools

Spring devtool is nothing but the developer’s tool which helps the developers to improve the time when we work with spring boot application, it is come with spring 1.3 release, it basically takes the current changes which we make into the application and restart the server which turns help in improving the development process and provide a better development environment for developers. To use this we need to add spring-boot-devtools in our project.

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,950 ratings)

Syntax:
For Gradel :

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
}

For Maven :

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

Functions of Spring Boot DevTools

It provides us many features which works differently like they can restart our application with all necessary changes, deployment on to the cloud, provides embedded server as well and etc. which makes the development easy and not time-consuming.

If we include the spring boot dev tool dependency into our project so start working and configure so many activities for us which helps us to reduce the time needed to run the application. These things are very much important when we are developing our application thus provide us with improving timing. Like we do not need to build war and jar by automatic restart it does its job, also we can debug and update our application which is at cloud hence making easy to manage and maintain. For this dev tools to enable into our application we do changes in the following:

  • In property file
  • pom.xml
  • make one new file with . prefix.

Example of Spring Boot DevTools

To build an example in spring boot follow the below steps: we need to add the dependency for dev tool into pom.xml while creating the project or it can be added further:

Code:

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

Now open spring initializer and create a project. Go to the main java class and run the project. It will show something like the below output.

Java Class:

package com.example.test.demotest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import com.example.test.config.JwtFilter;
@SpringBootApplication
public class DemoTestApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(DemoTestApplication.class, args);
}
}

Output:

Spring Boot DevTools-1.1

Features

spring boot provides us many features to debug, build, start our application. It also provides support for disabling and enable these developer’s tools into our application just by setting the property value to true or false into the property file. Features of developers tool are described below in details :

1. Remote Application

This feature includes a remote change that can be done efficiently over the network b the use of HTTP like we can debug our code and also we can update the files if any changes made. In the remote application, we have two types.

  • Remote debugging
  • Remote update
Remote Debugging

In remote debugging, we can debug our remote applications on the network by using HTTP. Also to use this we need to have a dev tool in our spring boot application as enabled.

  • Enable the Debug Port: Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n
  • Override the Default Port: spring.devtools.remote.debug.local-port=8010
Remote Update

If we make any change into our application so this feature just restarts the application. It continuously monitors our application if any changes occur in the classpath. So it just updates the remote resources and restarts the server. But for this, we do not need to stop the server all the changes are done when the remote server is running and up. It also provides us loggers statement.

2. Automatic Restart

So this feature of spring boot provides an automatic restart of the server whenever any change detected in files. so we do not need to manually build our code and deploy the war file all these things are managed by spring boot itself but for this, we need to use this dev tool package into our project. This feature can we well uses with live reload which we will discuss in the next point. we have gradel and maven as default build in a plugin.

we can restart our application by using the maven and gradel support we have.

make some configuration as:

  • pringApplication.setRegisterShutdownHook(false)
  • We can also disable the restart, spring.devtools.restart.enabled= false into the property file. or else we can also set this into our main() java class like below:

Syntax:

package com.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
public class TvvApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(TvvApplication.class, args);
}
}

3. Property Default

It is stated that the spring boot application uses a cache to provide better performance. But in production spring boot dev tool disables this caching features. To configured cache into spring boot application, we need to make an entry in the application.property file. but this dev tool feature will apply some configuration automatically. So by this, we do not need to reload our template files again and again.

4. Global Settings

To enable this global setting into our project we need to add one file into our home folder path. This file name will always start from a dot(.).

file name is .spring-boot-devtools.properties. so by adding this file globally, we apply this feature to all applications on our matching those who have dev tools packages enable in their projects. spring.devtools.reload.trigger-file=.reloadtrigger

5. LiveReload

This spring boot feature includes one embedded server which helps us to refresh the browser whenever we make any change. so whenever we make a change and go to the browser we will always going to have refresh data as we have in angular also. But sometimes we do not want this feature to enable our application so we can set this to: ing.devtools.livereload.enabled = false into a property file.

Recommended Articles

This is a guide to Spring Boot DevTools. Here we discuss the Introduction and spring boot devtools features along with an example and its code implementation. You may also have a look at the following articles to learn more –

  1. Spring Boot Annotations
  2. Spring Boot Versions
  3. Spring Boot Feature
  4. Spring Boot Application
Popular Course in this category
Spring Boot Training Program (2 Courses, 3 Project)
  2 Online Courses |  3 Hands-on Projects |  22+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Spring Framework Training (4 Courses, 6 Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more