This blog post describes how we can automatically restart our applications using the Developer Tools of Spring Boot. After we have finished this blog post, we:
- Understand what features the Developer Tools have and how Automatic Restart supports our application development.
- Can integrate IntelliJ IDEA and the Automatic Restart feature from the Developer Tools.
Let's get started.
Automatic Restart
The Developer Tools, which are provided as a module for the Spring Boot framework, are a module that can make application development experience much better.
The Developer Tools are consist of five features:
- Property Defaults
- Automatic Restart
- LiveReload
- Global Settings
- Remote Applications
Among the features above, the thing that gives a more significant speed impact for our development process is the second one -- Automatic Restart. Applications that use this restart automatically whenever files on the classpath change by monitoring a modification of the files in the folders such as ./out or ./build.
Installation of the Developer Tools is quite simple; add the following one-liner into the dependencies
directive of our build.gradle.
dependencies {
....
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
...
}
Integration IntelliJ and the Developer Tools
However, by only adding the one-liner above, the Developer Tools doesn't automatically restart our application yet. We need to complete two steps additionally.
First, we have to enable build project automatically. Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically.
Second, we change Registry configuration. Press command+shift+A (if you are using Windows press Ctrl+Shift+A), and search for Registry.
In the Registry, scroll the list to find the following configuration and enable it:
compiler.automake.allow.when.app.running
By finishing the two steps above, we are now able to develop our application without manual restart.
Finally what must be noted is how to start the application. The application must be started by running main
function instead of the Gradle task bootRun
.
Summary
This blog post has taught us two things:
- We learned what features the Developer Tools have and how Automatic Restart supports our application development.
- We learned how to integrated IntelliJ IDEA and the Automatic Restart feature from the Developer Tools.