Gradle 4 introduces a completely new model of dependency management, as documented here. It appears that Spring Boot Gradle plugin 1.5.3 doesn't correctly work with builds using the new Gradle configurations. Even though a dependency is specified in implementation, it needs to be duplicated in runtime, otherwise we get a ClassNotFoundException at runtime when running the uber jar. Also, using runtimeOnly instead of runtime causes similar ClassNotFoundException.
This ticket is to have a compatibility chart in the documentation showing what version of the Boot plugin is supposed to work with what versions of Gradle. Without that, it seems like a c*apshoot, where the plugin may or may not work depending on the project configuration.
Comment From: wilkinsona
Spring Boot 1.5.x supports Gradle 2 (2.9 or later) and 3. This is already described in the system requirements. Spring Boot 2 supports Gradle 4.
Comment From: asarkar
@wilkinsona I'd missed that little note regarding Gradle. Can we have a nice table like the one for servlet containers?
Comment From: wilkinsona
Yes, I guess we could add a table of the supported build systems and the versions we support.
Comment From: wakingrufus
Spring boot 1.4.x does not work with gradle 4.x
Comment From: philwebb
@wakingrufus Spring Boot 1.4 is end of life. Please upgrade to Spring Boot 2.0 if you can.
Comment From: wakingrufus
@philwebb Fair enough. My organization is currently working on an upgrade, I was just putting it out there, as it is something I have run into in terms of compatibility.
Comment From: philwebb
@wakingrufus 1.5 is still supported if that's an easier option for you.
Comment From: wilkinsona
Although please be aware that Boot 1.5 doesn’t officially support Gradle 4 either.
Comment From: edeesis
I ran into this recently as well with regards to implementation dependencies.
My workaround was to set the Spring boot plugin's customConfiguration to runtimeClasspath - which includes implementation and runtime dependencies.
springBoot {
customConfiguration = configurations.runtimeClasspath.name
}
Comment From: wilkinsona
Closing in favour of PR #14002.
Comment From: arutsudar
As per Spring Docs, below is a table which shows which version of gradle or maven to use for the corresponding Spring Boot version.
| Spring Boot version | Maven version | Gradle version |
|---|---|---|
| 2.2.x | 3.3+ | 5.x (4.10 is also supported but in a deprecated form) |
| 2.1.x | 3.3+ | 4.4+ |
| 2.0.x | 3.2+ | 4.x |
| 1.5.x | 3.2+ | 2.9 or 3.x |
| 1.4.x | 3.2+ | 1.12 or 2.x |
| 1.3.x | 3.2+ | 1.12 or 2.x |
| 1.2.x | 3.2+ | 1.12 or 2.x |
| 1.1.x | 3.0+ | 1.6+ |
| 1.0.x | 3.0+ | 1.6+ |
| 0.0.x | 3.0+ | 1.6+ |
Comment From: FyiurAmron
update for Gradle 8.x: official docs (see e.g. 2.7.9 & 2.7.10 ) state that Gradle 8.x requires Spring Boot at least 2.7.10 or 3.0.3; unofficially, at least 2.6.5 is required. With Spring Boot <= 2.6.4, you will have visible problems, like e.g. bootRun task disappearing ;)