Setting up a Spring Boot 2 app in Kotlin 1.2.21 on Fedora 27 with IntelliJ IDEA CE 2017.3, Gradle 4.5.1, and Auto-rebuild

Install gradle. I used the super safe method:

curl -s "" | bash
sdk install gradle 4.5.1

MitM attacks can't happen while you're using HTTPS. Not possible. (Definitely don't run the script as root.)

Fun fact: If you've just installed gradle, are confused why nothing's working in a Spring Boot project that for some reason can't find the main class, doesn't already have gradlew, and want to try running gradle with the gradle wrapper, just run

gradle wrapper

and you'll have your own ./gradlew and ./gradlew.bat files in your project directory. It probably won't solve your problem. You can try adding this to your build.gradle file, but it may or may not help:

springBoot {
  mainClassName = 'com.example.ExampleApplication'
Anyway, getting started with Spring Boot with Kotlin. Checkout the source for a basic Spring Boot Kotlin project:

Add spring-boot-devtools to the list of dependencies. (Modify the dependencies section so it looks like this:
dependencies {
    testCompile("org.springframework.boot:spring-boot-starter-test") {
        exclude(module = "junit")


    // Add this import

The build.gradle.kts file is written in, not Groovy, but Kotlin, using the Gradle Kotlin DSL plugin. Refer to the github repo for more documentation on using Kotlin with Gradle.

Then, add this import to the top of the build.gradle.kts file:
And under
tasks {

    withType<BootRun> {
        val sourceSets = the<JavaPluginConvention>().sourceSets

I'm not sure what that does or whether it's necessary, but it's copied from

After that, run gradle build --continuous or grade build -t (same thing, just shorter) or ./gradlew build -t (different thing, but using gradle wrapper is recommended for some reason, so that's what I actually run) in a new terminal window (in the root directory of your project) to get automatic rebuilds running. You'll also need to run gradle bootRun or ./gradlew bootRun.

I've set up IDEA to run gradle bootRun for me by importing the project as a gradle project, choosing Edit Configuration under the Run menu, clicking the plus button to create a new Run configuration, adding my project, and putting bootRun in the Tasks box.

I ran into an issue while trying to get IDEA set up. The main error it kept giving me, after having pulled all the gradle dependencies, was not being able to find basic Java classes like Java.lang.String. That was solved by following the steps in this support forum post:

Basically, make sure your SDKs are loaded properly. In my case, I had to refresh the JDK that was already detected (because I installed the JDK after installing and running IDEA). Also, make sure you have your JDK installed and not just your JRE. In Fedora, I ran dnf install java-1.8.0-openjdk-devel as specified here: It doesn't come with Fedora 27 by default.