1

Following the documentation I decided to use optional scope for Devtools using special propdeps plugin for Gradle:

Flagging the dependency as optional is a best practice that prevents devtools from being transitively applied to other modules using your project. Gradle does not support optional dependencies out-of-the-box so you may want to have a look to the propdeps-plugin in the meantime.

What I add to my build.gradle is:

buildscript {
    repositories {
        maven { url 'http://repo.spring.io/plugins-release' }
    }
    dependencies {
        classpath 'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE'
    }
}

apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'

dependencies {
    optional('org.springframework.boot:spring-boot-devtools')
}

and it does not seem to work at all.

At first, it breaks the ability to run @SpringBootApplication main method from Intellij (the problem was already described here: IntelliJ fails to start Spring Boot/Gradle application when using Spring Boot developer tools). But I can still start the app with bootRun goal so it is not a big problem if I still want to follow best practice declaring devtools as optinal.

The main problem is that it does not work for me at all. I run the app with bootRun and then execute compileJava --rerun-tasks expecting the app to be reloaded but it will not. Nothing happens. If I try to do the same with Devtools declared as runtime, then it performs quick reload without complete jvm restart.

I tried both: latest stable 1.5.7.RELEASE and the last available 2.0.0.M4.

Let me know if Devtools works for you when declared as optional in Gradle or if you know how to fix java.lang.NoClassDefFoundError when running main method from IntelliJ and optional Devtools?

Kirill
  • 6,762
  • 4
  • 51
  • 81

0 Answers0