• Bojan Belic

Spring Boot — Hot Swapping a Gradle project in IntelliJ with Kotlin support

** This article has been ported over from my Medium blog. - Original time of writing: Dec 24, 2017 **

If you happen to be using IntelliJ as your IDE for a Spring Boot project with Gradle & Kotlin support, and you want to make use of the spring-boot-devtools, than there is a little bit of configuration that needs to happen:

1. Enable auto-make on save

Millions have explained this before me, follow this guide:

2. Add ‘spring-boot-devtools’ dependency & ‘idea’ plugin in your build.gradle file

Simply add this line next to the ‘apply plugin’ lines in your file:

apply plugin: 'idea'

And afterward add this to your dependencies:


3. Redefine output dir location to match kotlin’s output dir

And this was the tricky part, add this block to your build.gradle:

idea {
   module {
      inheritOutputDirs = false
      outputDir = file("$buildDir/classes/kotlin/main")

4. $ gradle bootRun

Now open up a terminal instance, and run the bootRun gradle task. Once you edit and save one of your files in IntelliJ, you should see the terminal detect the change and restart the application.

You will still have to refresh your browser window yourself, but this is already a big improvement.