Spring Boot Dev Tools

In a typical application development environment, a developer would make some changes, build the project and deploy/start the application for new changes to take effect.

Using spring-boot-devtools, this process is also automated. Whenever files change in the classpath, applications using spring-boot-devtools will cause the application to restart. The benefit of this feature is the time required to verify the changes made is considerably reduced:

The thread that has spawned the application is not a main rather a restartedMain thread. Any changes made in the project be it a java file change will cause an automated restart of the project:

The spring-boot-devtools module can be included in any project to provide additional development-time features. To include devtools support, add the module dependency to your build, as shown in the following listings for Maven and Gradle:
Maven

    
        org.springframework.boot
        spring-boot-devtools
        true
    
Gradle
dependencies {
    developmentOnly("org.springframework.boot:spring-boot-devtools")
}
Developer tools are automatically disabled when running a fully packaged application. If your application is launched from java -jar or if it is started from a special classloader, then it is considered a “production application”. If that does not apply to you (i.e. if you run your application from a container), consider excluding devtools or set the -Dspring.devtools.restart.enabled=false system property.
Flagging the dependency as optional in Maven or using the developmentOnly configuration in Gradle (as shown above) prevents devtools from being transitively applied to other modules that use your project.

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days