Auto compilation in java springboot application

15 / May / 2016 by Sanchit 0 comments

To run springboot appllication there is a task “bootRun” which compile and run the application for one deployment lifecyle. This is good enough for the production, where auto compilation is not required.

In the dev environment auto compilation is used to avoid recompilation. Also it is very much needed to speed up the development time for developers.

For automatic compilation in springboot, there is a gradle plugin which need to be added in build.gradle.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.springframework:springloaded:1.2.4.RELEASE'
    }

You need to run the gradle application in the same way using “gradle bootRun” command. And Now you need to open a separate terminal instance same as in the project folder and run “gradle -t classes” command.

TwoTerminalZoom

This gradle “classes” task is continiously track the changed files in the current project directory.
All the changed files are re-compiled in this case and the .class files are replaced with the previous ones, so that all the changes can reflect to the output automatically.

Finally, we do not need to re compile the springboot application for any change in the source file.

FOUND THIS USEFUL? SHARE IT

Leave a comment -